diff options
Diffstat (limited to 'UCore.pas')
| -rw-r--r-- | UCore.pas | 100 |
1 files changed, 50 insertions, 50 deletions
@@ -20,7 +20,7 @@ unit UCore; interface -uses glib2, SyncObjs, Classes, GTKForms, GTKView, Libc, UGlibC_compat, UEngines, UCoreUtils, UProgress, UVFSCore; +uses glib2, SyncObjs, Classes, GTKForms, GTKView, ULibc, UEngines, UCoreUtils, UProgress, UVFSCore; function FillPanel(List: TList; ListView: TGTKListView; Engine: TPanelEngine; LeftPanel: boolean): boolean; @@ -234,8 +234,8 @@ begin if ListView.Items.Count = 0 then ListItem := ListView.Items.Add else ListItem := ListView.Items[0]; - Data := Libc.malloc(SizeOf(TDataItem)); - Libc.memset(Data, 0, SizeOf(TDataItem)); + Data := malloc(SizeOf(TDataItem)); + memset(Data, 0, SizeOf(TDataItem)); with Data^ do begin UpDir := True; IsDotFile := False; @@ -684,13 +684,13 @@ var DefResponse: integer; // Global variables for this function Res := True; BSize := DestEngine.GetBlockSize; - Buffer := Libc.malloc(BSize); + Buffer := malloc(BSize); if Buffer = nil then begin CopyFilesWorker_ErrorFunc(SenderThread, 1, errno, SourceFile); // Memory allocation failed - Libc.free(Buffer); + libc_free(Buffer); Exit; end; - Libc.memset(Buffer, 0, BSize); + memset(Buffer, 0, BSize); BytesWritten := 0; repeat @@ -708,7 +708,7 @@ var DefResponse: integer; // Global variables for this function Break; end; until (BytesRead = 0) or (BytesWritten < BytesRead); - Libc.free(Buffer); + libc_free(Buffer); if DestEngine.CloseFile(fdst) <> 0 then begin CopyFilesWorker_ErrorFunc(SenderThread, 4, errno, DestFile); // Cannot close target file @@ -1285,8 +1285,8 @@ begin if Pos('.', FileName) > 1 then FileName := ChangeFileExt(FileName, '.crc') else FileName := FileName + '.crc'; try - Buffer := Libc.malloc(CRCBlockSize); - Libc.memset(Buffer, 0, CRCBlockSize); + Buffer := malloc(CRCBlockSize); + memset(Buffer, 0, CRCBlockSize); except Application.MessageBox(LANGAnErrorOccuredWhileInitializingMemoryBlock, [mbOK], mbError, mbNone, mbOK); Exit; @@ -1298,7 +1298,7 @@ begin repeat Count := Engine.ReadFile(FD, Buffer, CRCBlockSize, Error); if Error <> 0 then begin - Libc.free(Buffer); + libc_free(Buffer); Engine.CloseFile(FD); Exit; end; @@ -1319,7 +1319,7 @@ begin if Length(s) > 0 then ProcessLine(s); Engine.CloseFile(FD); - Libc.free(Buffer); + libc_free(Buffer); Result := True; end; @@ -1411,8 +1411,8 @@ begin if Assigned(Stat) then MergeBlockSize := ComputeBlockSize(Stat^.Size) else MergeBlockSize := 65536*4; try - Buffer := Libc.malloc(MergeBlockSize); - Libc.memset(Buffer, 0, MergeBlockSize); + Buffer := malloc(MergeBlockSize); + memset(Buffer, 0, MergeBlockSize); except FCancelMessage := LANGAnErrorOccuredWhileInitializingMemoryBlock; FShowCancelMessage := True; @@ -1422,7 +1422,7 @@ begin if Error <> 0 then begin FCancelMessage := Format(LANGAnErrorOccuredWhileOpeningFileSS, [StrToUTF8(TargetName), GetErrorString(Error)]); FShowCancelMessage := True; - Libc.free(Buffer); + libc_free(Buffer); Exit; end; @@ -1470,7 +1470,7 @@ begin end else ShowMessageBox(Format(LANGMergeOfSSucceeded_NoCRCFileAvailable, [StrToUTF8(ExtractFileName(TargetFinalName))]), [mbOK], mbInfo, mbNone, mbOK); Engine.CloseFile(FD); end; - Libc.free(Buffer); + libc_free(Buffer); SenderThread.FDoneThread := True; end; @@ -1611,8 +1611,8 @@ begin List := TList.Create; try - Buffer := Libc.malloc(SplitBlockSize); - Libc.memset(Buffer, 0, SplitBlockSize); + Buffer := malloc(SplitBlockSize); + memset(Buffer, 0, SplitBlockSize); except FCancelMessage := LANGAnErrorOccuredWhileInitializingMemoryBlock; FShowCancelMessage := True; @@ -1621,7 +1621,7 @@ begin FD := Engine.OpenFile(ParamString1, omRead, Error); if Error <> 0 then begin FCancelMessage := Format(LANGAnErrorOccuredWhileOpeningFileSS, [StrToUTF8(ParamString1), GetErrorString(Error)]); - Libc.free(Buffer); + libc_free(Buffer); Exit; end; FilePath := IncludeTrailingPathDelimiter(ProcessPattern(Engine, ParamString2, Engine.Path, '', True)); @@ -2363,8 +2363,8 @@ end; (********************************************************************************************************************************) (********************************************************************************************************************************) procedure FillDefaultFstabMounterItems; -var fd: PGlibc_IOFile; - mntent: PGlibc_mntent; +var fd: PFILE; + mntent: Pmntent; MounterItem: TMounterItem; begin while MounterList.Count > 0 do begin @@ -2373,10 +2373,10 @@ begin end; MounterList.Clear; - fd := glibc_setmntent(_PATH_MNTTAB, 'r'); + fd := setmntent(_PATH_MNTTAB, 'r'); if fd = nil then Exit; // Get mount name - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); while mntent <> nil do begin if (mntent^.mnt_dir <> '/') and (mntent^.mnt_dir <> '/boot') and (Pos('/proc', mntent^.mnt_dir) <> 1) and (Pos('/dev', mntent^.mnt_dir) <> 1) and (mntent^.mnt_dir <> 'swap') and (mntent^.mnt_dir <> '') then @@ -2396,53 +2396,53 @@ begin MounterItem.DeviceType := 0; MounterList.Add(MounterItem); end; - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); end; - glibc_endmntent(fd); + endmntent(fd); end; function TMounterItem.Mounted: boolean; -var fd: PGlibc_IOFile; - mntent: PGlibc_mntent; +var fd: PFILE; + mntent: Pmntent; begin Result := False; - fd := glibc_setmntent(_PATH_MOUNTED, 'r'); + fd := setmntent(_PATH_MOUNTED, 'r'); if fd = nil then Exit; // Get mount name - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); while mntent <> nil do begin // DebugMsg(['mntent^.mnt_dir = ', Int64(mntent^.mnt_dir)]); // DebugMsg(['mntent^.mnt_dir = ', mntent^.mnt_dir]); // DebugMsg(['sizeof(mntent^.mnt_dir) = ', sizeof(mntent^.mnt_dir)]); -// DebugMsg(['sizeof(TGlibc_mntent) = ', sizeof(TGlibc_mntent)]); +// DebugMsg(['sizeof(Tmntent) = ', sizeof(Tmntent)]); // DebugMsg(['string(mntent^.mnt_dir) = ', string(mntent^.mnt_dir)]); // DebugMsg(['MountPath = ', MountPath]); if mntent^.mnt_dir = MountPath then begin Result := True; Break; end; - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); end; - glibc_endmntent(fd); + endmntent(fd); end; function TMounterItem.IsInFSTab: boolean; -var fd: PGlibc_IOFile; - mntent: PGlibc_mntent; +var fd: PFILE; + mntent: Pmntent; begin Result := False; - fd := glibc_setmntent(_PATH_MNTTAB, 'r'); + fd := setmntent(_PATH_MNTTAB, 'r'); if fd = nil then Exit; // Get mount name - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); while mntent <> nil do begin if (mntent^.mnt_dir = MountPath) and (mntent^.mnt_fsname = Device) then begin Result := True; Break; end; - mntent := glibc_getmntent(fd); + mntent := getmntent(fd); end; - glibc_endmntent(fd); + endmntent(fd); end; function TMounterItem.Mount: boolean; @@ -2531,7 +2531,7 @@ begin end; procedure GetDirSize(AListView: TGTKListView; Engine: TPanelEngine; DataList: TList; AllItems: boolean); -var t: __time_t; +var t: time_t; b: boolean; FRemoteWait: TFRemoteWait; @@ -2581,9 +2581,9 @@ var t: __time_t; if (ASize < 0) or FMainEscPressed or (Assigned(FRemoteWait) and FRemoteWait.Cancelled) then Exit; Data^.Size := ASize; s := FormatSize(ASize, 0); - Libc.free(Data^.ColumnData[3]); -// Data^.ColumnData[3] := Libc.malloc(Length(s) + 1); -// Libc.memset(Data^.ColumnData[3], 0, Length(s) + 1); + libc_free(Data^.ColumnData[3]); +// Data^.ColumnData[3] := malloc(Length(s) + 1); +// memset(Data^.ColumnData[3], 0, Length(s) + 1); Data^.ColumnData[3] := strdup(PChar(s)); except end; end; @@ -2688,15 +2688,15 @@ end; } (********************************************************************************************************************************) (********************************************************************************************************************************) function PurgeDirectory(APath: string): boolean; -var Handle : PDirectoryStream; +var Handle : PDIR; DirEnt : PDirent64; - StatBuf : PGlibc_stat64; + StatBuf : Pstat64; Buf : PChar; begin try Result := True; APath := IncludeTrailingPathDelimiter(APath); - Handle := Libc.opendir(PChar(APath)); + Handle := opendir(PChar(APath)); if not Assigned(Handle) then begin Result := False; Exit; @@ -2706,22 +2706,22 @@ begin if Assigned(DirEnt) and Assigned(PChar(@DirEnt^.d_name[0])) then begin Buf := Pchar(@DirEnt^.d_name[0]); if (Buf <> '.') and (Buf <> '..') and (DirEnt^.d_name[0] <> #0) then begin - StatBuf := Libc.malloc(sizeof(TGlibc_stat64)); - Libc.memset(StatBuf, 0, sizeof(TGlibc_stat64)); - if glibc_lstat64(PChar(APath + string(Buf)), StatBuf) = 0 then + StatBuf := malloc(sizeof(Tstat64)); + memset(StatBuf, 0, sizeof(Tstat64)); + if lstat64(PChar(APath + string(Buf)), StatBuf) = 0 then if __S_ISTYPE(StatBuf.st_mode, __S_IFDIR) then PurgeDirectory(APath + string(Buf)) else begin // DebugMsg(['Removing ', APath + string(Buf)]); - Result := Result and (Libc.remove(PChar(APath + string(Buf))) = 0); + Result := Result and (libc_remove(PChar(APath + string(Buf))) = 0); end; - Libc.free(StatBuf); + libc_free(StatBuf); end; end; until DirEnt = nil; closedir(Handle); // DebugMsg(['Removing ', ExcludeTrailingPathDelimiter(APath)]); - Result := Result and (Libc.remove(PChar(ExcludeTrailingPathDelimiter(APath))) = 0); + Result := Result and (libc_remove(PChar(ExcludeTrailingPathDelimiter(APath))) = 0); except on E: Exception do DebugMsg(['*** Exception raised in UCore.PurgeDirectory(APath = ', APath, '): ', E.ClassName, ': ', E.Message]); end; |
