mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-30 00:02:45 +02:00
splitted off unit FileUtil, it doesn't depend on other LCL units
git-svn-id: trunk@6080 -
This commit is contained in:
parent
b0e1042048
commit
bcf90ce19b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1088,6 +1088,7 @@ lcl/extdlgs.pas svneol=native#text/pascal
|
||||
lcl/extendedstrings.pas svneol=native#text/pascal
|
||||
lcl/extgraphics.pas svneol=native#text/pascal
|
||||
lcl/filectrl.pp svneol=native#text/pascal
|
||||
lcl/fileutil.pas svneol=native#text/pascal
|
||||
lcl/forms.pp svneol=native#text/pascal
|
||||
lcl/fpcadds.pas svneol=native#text/pascal
|
||||
lcl/graphics.pp svneol=native#text/pascal
|
||||
|
@ -26,7 +26,7 @@ unit HelpFPDoc;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, FileCtrl, HelpIntf, HelpHTML;
|
||||
Classes, SysUtils, LCLProc, FileUtil, HelpIntf, HelpHTML;
|
||||
|
||||
type
|
||||
{ TFPDocHTMLHelpDatabase }
|
||||
|
@ -22,7 +22,7 @@ unit HelpHTML;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, Forms, Process, FileCtrl, ConfigStorage,
|
||||
Classes, SysUtils, LCLProc, Forms, Process, FileUtil, ConfigStorage,
|
||||
PropEdits, ObjInspStrConsts, HelpIntf;
|
||||
|
||||
type
|
||||
|
@ -27,7 +27,7 @@ unit HelpIntf;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, Controls, FileCtrl, ConfigStorage,
|
||||
Classes, SysUtils, LCLProc, Controls, FileUtil, ConfigStorage,
|
||||
ObjInspStrConsts;
|
||||
|
||||
type
|
||||
|
@ -22,7 +22,7 @@ unit ProjectIntf;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, FileCtrl;
|
||||
Classes, SysUtils, LCLProc, FileUtil;
|
||||
|
||||
const
|
||||
FileDescNamePascalUnit = 'unit';
|
||||
|
@ -36,6 +36,7 @@ uses
|
||||
StringHashList, ExtendedStrings, DynamicArray, UTrace, TextStrings,
|
||||
// base types and base functions
|
||||
LCLProc, LCLType, LCLResCache, GraphMath, FileCtrl, LMessages, LResources,
|
||||
FileUtil,
|
||||
// the interface base
|
||||
InterfaceBase,
|
||||
{$IFNDEF DisableFPImage}IntfGraphics,{$ENDIF}
|
||||
@ -63,6 +64,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.22 2004/09/27 21:45:44 vincents
|
||||
splitted off unit FileUtil, it doesn't depend on other LCL units
|
||||
|
||||
Revision 1.21 2004/09/24 13:45:31 mattias
|
||||
fixed TCanvas.TextRect Delphi compatible Rect and added TBarChart from Michael VC
|
||||
|
||||
|
@ -37,7 +37,7 @@ unit Dialogs;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLIntf, InterfaceBase, FileCtrl, LCLStrConsts, LCLType,
|
||||
Classes, SysUtils, LCLIntf, InterfaceBase, FileUtil, LCLStrConsts, LCLType,
|
||||
LMessages, LCLProc, Forms, Controls, GraphType, Graphics, Buttons, StdCtrls,
|
||||
LCLClasses;
|
||||
|
||||
@ -420,6 +420,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.54 2004/09/27 21:45:44 vincents
|
||||
splitted off unit FileUtil, it doesn't depend on other LCL units
|
||||
|
||||
Revision 1.53 2004/09/14 21:30:37 vincents
|
||||
replaced writeln by DebugLn
|
||||
|
||||
|
@ -27,9 +27,9 @@ unit ExtDlgs;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LResources, LCLType, LCLStrConsts, Controls,
|
||||
Dialogs, GraphType, Graphics, ExtCtrls, StdCtrls, Forms, FileCtrl, Calendar,
|
||||
Buttons;
|
||||
Classes, SysUtils, LCLProc, LResources, LCLType, LCLStrConsts, FileUtil,
|
||||
Controls, Dialogs, GraphType, Graphics, ExtCtrls, StdCtrls, Forms,
|
||||
Calendar, Buttons;
|
||||
|
||||
type
|
||||
|
||||
|
@ -41,7 +41,7 @@ uses
|
||||
// otherwise IE 55665566 occurs.
|
||||
Controls,
|
||||
{$endif}
|
||||
StdCtrls;
|
||||
StdCtrls, FileUtil;
|
||||
|
||||
Type
|
||||
|
||||
@ -132,90 +132,10 @@ Type
|
||||
property Visible;
|
||||
end;
|
||||
|
||||
|
||||
// file attributes and states
|
||||
function CompareFilenames(const Filename1, Filename2: string): integer;
|
||||
function CompareFilenames(const Filename1, Filename2: string;
|
||||
ResolveLinks: boolean): integer;
|
||||
function CompareFilenames(Filename1: PChar; Len1: integer;
|
||||
Filename2: PChar; Len2: integer; ResolveLinks: boolean): integer;
|
||||
function FilenameIsAbsolute(TheFilename: string):boolean;
|
||||
procedure CheckIfFileIsExecutable(const AFilename: string);
|
||||
procedure CheckIfFileIsSymlink(const AFilename: string);
|
||||
function FileIsReadable(const AFilename: string): boolean;
|
||||
function FileIsWritable(const AFilename: string): boolean;
|
||||
function FileIsText(const AFilename: string): boolean;
|
||||
function FileIsExecutable(const AFilename: string): boolean;
|
||||
function FileIsSymlink(const AFilename: string): boolean;
|
||||
function GetFileDescription(const AFilename: string): string;
|
||||
function ReadAllLinks(const Filename: string;
|
||||
ExceptionOnError: boolean): string;
|
||||
|
||||
// directories
|
||||
function DirPathExists(const FileName: String): Boolean;
|
||||
function ForceDirectory(DirectoryName: string): boolean;
|
||||
function DeleteDirectory(const DirectoryName: string;
|
||||
OnlyChilds: boolean): boolean;
|
||||
function ProgramDirectory: string;
|
||||
|
||||
// filename parts
|
||||
function ExtractFileNameOnly(const AFilename: string): string;
|
||||
function CompareFileExt(const Filename, Ext: string;
|
||||
CaseSensitive: boolean): integer;
|
||||
function FilenameIsPascalUnit(const Filename: string): boolean;
|
||||
function AppendPathDelim(const Path: string): string;
|
||||
function ChompPathDelim(const Path: string): string;
|
||||
function TrimFilename(const AFilename: string): string;
|
||||
function CleanAndExpandFilename(const Filename: string): string;
|
||||
function CleanAndExpandDirectory(const Filename: string): string;
|
||||
function FileIsInPath(const Filename, Path: string): boolean;
|
||||
function FileIsInDirectory(const Filename, Directory: string): boolean;
|
||||
function FileInFilenameMasks(const Filename, Masks: string): boolean;
|
||||
|
||||
// file search
|
||||
type
|
||||
TSearchFileInPathFlag = (
|
||||
sffDontSearchInBasePath,
|
||||
sffSearchLoUpCase
|
||||
);
|
||||
TSearchFileInPathFlags = set of TSearchFileInPathFlag;
|
||||
|
||||
function SearchFileInPath(const Filename, BasePath, SearchPath,
|
||||
Delimiter: string; Flags: TSearchFileInPathFlags): string;
|
||||
function GetAllFilesMask: string;
|
||||
|
||||
// file actions
|
||||
function ReadFileToString(const Filename: string): string;
|
||||
function CopyFile(const SrcFilename, DestFilename: string): boolean;
|
||||
function CopyFile(const SrcFilename, DestFilename: string; PreserveTime: boolean): boolean;
|
||||
function GetTempFilename(const Path, Prefix: string): string;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF win32}
|
||||
Dos;
|
||||
{$ELSE}
|
||||
{$IFDEF Ver1_0}Linux{$ELSE}Unix,BaseUnix{$ENDIF};
|
||||
{$ENDIF}
|
||||
|
||||
var
|
||||
UpChars: array[char] of char;
|
||||
|
||||
|
||||
{$I filectrl.inc}
|
||||
|
||||
procedure InternalInit;
|
||||
var
|
||||
c: char;
|
||||
begin
|
||||
for c:=Low(char) to High(char) do begin
|
||||
UpChars[c]:=upcase(c);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TCustomFileListBox }
|
||||
|
||||
procedure TCustomFileListBox.UpdateFileList;
|
||||
@ -391,13 +311,13 @@ begin
|
||||
RegisterComponents('Misc',[TFileListBox]);
|
||||
end;
|
||||
|
||||
initialization
|
||||
InternalInit;
|
||||
|
||||
end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.31 2004/09/27 21:45:44 vincents
|
||||
splitted off unit FileUtil, it doesn't depend on other LCL units
|
||||
|
||||
Revision 1.30 2004/09/27 10:35:51 vincents
|
||||
Added CopyFile with PerserveTime parameter
|
||||
|
||||
|
95
lcl/fileutil.pas
Normal file
95
lcl/fileutil.pas
Normal file
@ -0,0 +1,95 @@
|
||||
unit FileUtil;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils;
|
||||
|
||||
// file attributes and states
|
||||
function CompareFilenames(const Filename1, Filename2: string): integer;
|
||||
function CompareFilenames(const Filename1, Filename2: string;
|
||||
ResolveLinks: boolean): integer;
|
||||
function CompareFilenames(Filename1: PChar; Len1: integer;
|
||||
Filename2: PChar; Len2: integer; ResolveLinks: boolean): integer;
|
||||
function FilenameIsAbsolute(TheFilename: string):boolean;
|
||||
procedure CheckIfFileIsExecutable(const AFilename: string);
|
||||
procedure CheckIfFileIsSymlink(const AFilename: string);
|
||||
function FileIsReadable(const AFilename: string): boolean;
|
||||
function FileIsWritable(const AFilename: string): boolean;
|
||||
function FileIsText(const AFilename: string): boolean;
|
||||
function FileIsExecutable(const AFilename: string): boolean;
|
||||
function FileIsSymlink(const AFilename: string): boolean;
|
||||
function GetFileDescription(const AFilename: string): string;
|
||||
function ReadAllLinks(const Filename: string;
|
||||
ExceptionOnError: boolean): string;
|
||||
|
||||
// directories
|
||||
function DirPathExists(const FileName: String): Boolean;
|
||||
function ForceDirectory(DirectoryName: string): boolean;
|
||||
function DeleteDirectory(const DirectoryName: string;
|
||||
OnlyChilds: boolean): boolean;
|
||||
function ProgramDirectory: string;
|
||||
|
||||
// filename parts
|
||||
function ExtractFileNameOnly(const AFilename: string): string;
|
||||
function CompareFileExt(const Filename, Ext: string;
|
||||
CaseSensitive: boolean): integer;
|
||||
function FilenameIsPascalUnit(const Filename: string): boolean;
|
||||
function AppendPathDelim(const Path: string): string;
|
||||
function ChompPathDelim(const Path: string): string;
|
||||
function TrimFilename(const AFilename: string): string;
|
||||
function CleanAndExpandFilename(const Filename: string): string;
|
||||
function CleanAndExpandDirectory(const Filename: string): string;
|
||||
function FileIsInPath(const Filename, Path: string): boolean;
|
||||
function FileIsInDirectory(const Filename, Directory: string): boolean;
|
||||
function FileInFilenameMasks(const Filename, Masks: string): boolean;
|
||||
|
||||
// file search
|
||||
type
|
||||
TSearchFileInPathFlag = (
|
||||
sffDontSearchInBasePath,
|
||||
sffSearchLoUpCase
|
||||
);
|
||||
TSearchFileInPathFlags = set of TSearchFileInPathFlag;
|
||||
|
||||
function SearchFileInPath(const Filename, BasePath, SearchPath,
|
||||
Delimiter: string; Flags: TSearchFileInPathFlags): string;
|
||||
function GetAllFilesMask: string;
|
||||
|
||||
// file actions
|
||||
function ReadFileToString(const Filename: string): string;
|
||||
function CopyFile(const SrcFilename, DestFilename: string): boolean;
|
||||
function CopyFile(const SrcFilename, DestFilename: string; PreserveTime: boolean): boolean;
|
||||
function GetTempFilename(const Path, Prefix: string): string;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF win32}
|
||||
Dos;
|
||||
{$ELSE}
|
||||
{$IFDEF Ver1_0}Linux{$ELSE}Unix,BaseUnix{$ENDIF};
|
||||
{$ENDIF}
|
||||
|
||||
var
|
||||
UpChars: array[char] of char;
|
||||
|
||||
|
||||
{$I filectrl.inc}
|
||||
|
||||
procedure InternalInit;
|
||||
var
|
||||
c: char;
|
||||
begin
|
||||
for c:=Low(char) to High(char) do begin
|
||||
UpChars[c]:=upcase(c);
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
InternalInit;
|
||||
|
||||
end.
|
||||
|
@ -39,7 +39,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Buttons, ExtCtrls, StdCtrls,
|
||||
LazarusIDEStrConsts, Dialogs, AVL_Tree, FileCtrl, IDEProcs, IDEOptionDefs,
|
||||
LazarusIDEStrConsts, Dialogs, AVL_Tree, FileUtil, IDEProcs, IDEOptionDefs,
|
||||
ComponentReg, PackageDefs, PackageSystem;
|
||||
|
||||
type
|
||||
|
@ -39,7 +39,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Buttons, StdCtrls, ExtCtrls,
|
||||
Dialogs, FileCtrl, ComCtrls, LazarusIDEStrConsts, IDEOptionDefs, InputHistory,
|
||||
Dialogs, FileUtil, ComCtrls, LazarusIDEStrConsts, IDEOptionDefs, InputHistory,
|
||||
AVL_Tree, CodeToolManager, IDEDefs, IDEProcs, EnvironmentOpts, PackageSystem,
|
||||
PackageDefs, ComponentReg;
|
||||
|
||||
|
@ -47,7 +47,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LResources, Graphics, Laz_XMLCfg, AVL_Tree,
|
||||
DefineTemplates, CodeToolManager, EditDefineTree, CompilerOptions, Forms,
|
||||
FileCtrl, LazarusIDEStrConsts, IDEProcs, ComponentReg, TransferMacros,
|
||||
FileUtil, LazarusIDEStrConsts, IDEProcs, ComponentReg, TransferMacros,
|
||||
FileReferenceList, PublishModule;
|
||||
|
||||
type
|
||||
|
@ -39,7 +39,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, StdCtrls, ComCtrls, Buttons, LResources,
|
||||
Graphics, LCLType, LCLProc, Menus, Dialogs, FileCtrl, Laz_XMLCfg, AVL_Tree,
|
||||
Graphics, LCLType, LCLProc, Menus, Dialogs, FileUtil, Laz_XMLCfg, AVL_Tree,
|
||||
IDEProcs, LazConf, LazarusIDEStrConsts, IDEOptionDefs, IDEDefs,
|
||||
CompilerOptions, CompilerOptionsDlg, ComponentReg, PackageDefs, PkgOptionsDlg,
|
||||
AddToPackageDlg, PkgVirtualUnitEditor, PackageSystem;
|
||||
|
@ -38,7 +38,7 @@ unit PackageLinks;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, AVL_Tree, Laz_XMLCfg, LCLProc, FileCtrl, IDEProcs,
|
||||
Classes, SysUtils, AVL_Tree, Laz_XMLCfg, LCLProc, FileUtil, IDEProcs,
|
||||
EnvironmentOpts, PackageDefs, LazConf;
|
||||
|
||||
type
|
||||
|
@ -45,7 +45,7 @@ uses
|
||||
{$IFDEF IDE_MEM_CHECK}
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils, AVL_Tree, Laz_XMLCfg, FileCtrl, LCLProc, Forms, Controls,
|
||||
Classes, SysUtils, AVL_Tree, Laz_XMLCfg, FileUtil, LCLProc, Forms, Controls,
|
||||
Dialogs, LazarusIDEStrConsts, IDEProcs, LazConf, CompilerOptions,
|
||||
PackageLinks, PackageDefs, LazarusPackageIntf, ComponentReg, RegisterFCL,
|
||||
RegisterLCL, RegisterSynEdit, RegisterIDEIntf;
|
||||
|
@ -45,7 +45,7 @@ uses
|
||||
MemCheck,
|
||||
{$ENDIF}
|
||||
// FCL, LCL
|
||||
Classes, SysUtils, LCLProc, Forms, Controls, FileCtrl, Dialogs, Menus,
|
||||
Classes, SysUtils, LCLProc, Forms, Controls, FileUtil, Dialogs, Menus,
|
||||
// codetools
|
||||
CodeToolManager, CodeCache, BasicCodeTools, Laz_XMLCfg, AVL_Tree,
|
||||
// IDE
|
||||
|
@ -39,7 +39,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
|
||||
StdCtrls, FileCtrl, PackageDefs;
|
||||
StdCtrls, FileUtil, PackageDefs;
|
||||
|
||||
type
|
||||
TEditVirtualUnitDialog = class(TForm)
|
||||
|
@ -29,7 +29,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, LResources, StdCtrls,
|
||||
Buttons, FileCtrl, IDEProcs, UFrmAddComponent;
|
||||
Buttons, FileUtil, IDEProcs, UFrmAddComponent;
|
||||
|
||||
Type
|
||||
TRComponent = class(TObject)
|
||||
|
Loading…
Reference in New Issue
Block a user