Unit msefileutils

Description

This item has no description.

Overview

Classes, Interfaces, Objects and Records

Name Description
Class tcustomfiledatalist  
Class tfiledatalist  

Functions and Procedures

function quotefilename(const name: filenamety): filenamety; overload;
function quotefilename(const directory,name: filenamety): filenamety; overload;
function quotefilename(const names: filenamearty): filenamety; overload;
function quotefilename(const names: array of filenamety): filenamety; overload;
procedure unquotefilename(const names: filenamety; var result: filenamearty); overload;
function unquotefilename(const name: filenamety): filenamety; overload;
function extractrootpath(var names: filenamearty): filenamety;
function combinerootpath(const rootpath: filenamety; const names: filenamearty): filenamearty; overload;
function combinerootpath(const rootpaths: filenamearty; const name: filenamety): filenamearty; overload;
function syscommandline(const acommandline: filenamety): filenamety;
function filepath( directory: filenamety; filename: filenamety; kind: filekindty = fk_default; relative: boolean = false): filenamety; overload;
function filepath( path: filenamety; kind: filekindty = fk_default; relative: boolean = false): filenamety; overload;
function relativepath(const path: filenamety; const root: filenamety = ''; const kind: filekindty = fk_default): filenamety;
function relocatepath(const olddir,newdir: filenamety; var apath: filenamety; const options: pathrelocateoptionsty = []): boolean;
function isrelativepath(const path: filenamety): boolean;
function isrootdir(const path: filenamety): boolean;
function removelastpathsection(path: filenamety): filenamety;
function getlastpathsection(const path: filenamety): filenamety;
function removelastdir(path: filenamety; var newpath: filenamety): filenamety;
procedure splitfilepath(const path: filenamety; out directory,filename: filenamety); overload;
procedure splitfilepath(const path: filenamety; out directory,filename,fileext: filenamety); overload;
function splitfilepath(const path: filenamety): filenamearty;
function splitrootpath(const path: filenamety): filenamearty;
function mergerootpath(const segments: filenamearty): filenamety;
function checkfilename(const filename,mask: filenamety; casesensitive: boolean = false): boolean; overload;
function checkfilename(const filename: filenamety; const mask: filenamearty; casesensitive: boolean = false): boolean; overload;
function checkfilename(const filename: filenamety; const dirstream: dirstreamty): boolean; overload;
function hasmaskchars(const filename: filenamety): boolean;
function issamefilename(const a,b: filenamety): boolean;
function issamefilepath(const a,b: filenamety): boolean;
function filename(const path: filenamety): filenamety;
function filedir(const path: filenamety): filenamety;
function filenamebase(const path: filenamety): filenamety;
function fileext(const path: filenamety): filenamety;
function removefileext(const path: filenamety): filenamety;
function hasfileext(const path: filenamety): boolean;
function checkfileext(const path: filenamety; const extensions: array of filenamety): boolean;
function replacefileext(const path,newext: filenamety): filenamety;
function tomsefilepath(const path: filenamety; const quoted: boolean = false): filenamety;
procedure tomsefilepath1(var path: filenamety; const quoted: boolean = false);
function tosysfilepath(const path: filenamety; const quoted: boolean = false): filenamety;
function tosysfilepath(const path: filenamearty; const quoted: boolean = false): filenamearty;
procedure tosysfilepath1(var path: filenamety; const quoted: boolean = false);
function searchfile(const filename: filenamety; dir: boolean = false; const aoptions: dirstreamoptionsty = []): filenamety; overload;
function searchfile(const afilename: filenamety; const adirnames: array of filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamety; overload;
function searchfile(const afilename: filenamety; const adirname: filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamety; overload;
function searchfiles(const afilename: filenamety; const adirnames: array of filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamearty; overload;
function searchfiles(const afilename: filenamety; const adirname: filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamearty; overload;
function searchfilenames(const afilename: filenamety; const adirname: filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamearty;
function dirhasentries(const adirname: filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []): boolean;
function findfile(filename: filenamety; const dirnames: array of filenamety; var path: filenamety): boolean; overload;
function findfile(filename: filenamety; var path: filenamety): boolean; overload;
function findfile(const filename: filenamety; const dirnames: array of filenamety): boolean; overload;
function findfile(const filename: filenamety): boolean; overload;
function finddir(const filename: filenamety): boolean;
function findfileordir(const filename: filenamety): boolean;
function uniquefilename(const path: filenamety): filenamety;
function isrootpath(const path: filenamety): boolean;
function copyfile(const oldfile,newfile: filenamety; const canoverwrite: boolean = true): boolean;
function trycopyfile(const oldfile,newfile: filenamety; const canoverwrite: boolean = true): boolean;
function renamefile(const oldname,newname: filenamety; const canoverwrite: boolean = true): boolean;
function deletefile(const filename: filenamety): boolean;
function trydeletefile(const filename: filenamety): boolean;
procedure createdir(const path: filenamety; const rights: filerightsty = defaultdirrights);
procedure createdirpath(const path: filenamety; const rights: filerightsty = defaultdirrights);
function deletedir(const path: filenamety): boolean;
function trydeletedir(const path: filenamety): boolean;
function getcurrentdir: filenamety; deprecated;
function getcurrentdirmse: filenamety;
function setcurrentdir(const path: filenamety): filenamety; deprecated;
function setcurrentdirmse(const path: filenamety): filenamety;
function trysetcurrentdirmse(const path: filenamety): boolean; overload;
function trysetcurrentdirmse(const path: filenamety; out pathbefore: msestring): boolean; overload;
procedure clearfileinfo(var info: fileinfoty);
procedure initdirfileinfo(var info: fileinfoty; const aname: filenamety; open: boolean = false);
function getfileinfo(const path: filenamety; var info: fileinfoty): boolean;
function getfilemodtime(const path: filenamety): tdatetime;
function filesystemiscaseinsensitive: boolean;
function compfileinfos(const info1,info2: fileinfoty): filechangesty;
function compfiletime(const a,b: tdatetime): integer;
function intermediatefilename(const aname: filenamety): filenamety;
function msegettempdir: filenamety;
function msegettempfilename(const aname: filenamety): filenamety;

Types

filelistoptionty = (...);
filelistoptionsty = set of filelistoptionty;
filekindty = (...);
filechangety = (...);
filechangesty = set of filechangety;
checkfileeventty = procedure (const sender: tobject; const streaminfo: dirstreaminfoty; const fileinfo: fileinfoty; var accept: boolean) of object;
pathrelocateoptionty = (...);
pathrelocateoptionsty = set of pathrelocateoptionty;
filesortfuncty = function(const l,r: fileinfoty): integer of object;

Constants

sortflags: filelistoptionsty = [flo_sortname,flo_sorttime,flo_sortsize];
intermediatefileextension = '.tmp';

Description

Functions and Procedures

function quotefilename(const name: filenamety): filenamety; overload;

This item has no description.

function quotefilename(const directory,name: filenamety): filenamety; overload;

This item has no description.

function quotefilename(const names: filenamearty): filenamety; overload;

This item has no description.

function quotefilename(const names: array of filenamety): filenamety; overload;

This item has no description.

procedure unquotefilename(const names: filenamety; var result: filenamearty); overload;

This item has no description.

function unquotefilename(const name: filenamety): filenamety; overload;

This item has no description.

function extractrootpath(var names: filenamearty): filenamety;

This item has no description.

function combinerootpath(const rootpath: filenamety; const names: filenamearty): filenamearty; overload;

This item has no description.

function combinerootpath(const rootpaths: filenamearty; const name: filenamety): filenamearty; overload;

This item has no description.

function syscommandline(const acommandline: filenamety): filenamety;

This item has no description.

function filepath( directory: filenamety; filename: filenamety; kind: filekindty = fk_default; relative: boolean = false): filenamety; overload;

Returns the path built from directory and filename (directory is ignored if filename starts with a root segment). filename can also start with ~/, expanded to sys_getuserhomedir()/..., or ˆ/, expanded to sys_getapphomedir()/....

function filepath( path: filenamety; kind: filekindty = fk_default; relative: boolean = false): filenamety; overload;

This item has no description.

function relativepath(const path: filenamety; const root: filenamety = ''; const kind: filekindty = fk_default): filenamety;

Returns path relative to root (or to the current directory if root is empty).

function relocatepath(const olddir,newdir: filenamety; var apath: filenamety; const options: pathrelocateoptionsty = []): boolean;

Searches the file apath in newdir relative to olddir, or in its original location; updates apath and returns True if found.

function isrelativepath(const path: filenamety): boolean;

This item has no description.

function isrootdir(const path: filenamety): boolean;

This item has no description.

function removelastpathsection(path: filenamety): filenamety;

This item has no description.

function getlastpathsection(const path: filenamety): filenamety;

This item has no description.

function removelastdir(path: filenamety; var newpath: filenamety): filenamety;

This item has no description.

procedure splitfilepath(const path: filenamety; out directory,filename: filenamety); overload;

This item has no description.

procedure splitfilepath(const path: filenamety; out directory,filename,fileext: filenamety); overload;

This item has no description.

function splitfilepath(const path: filenamety): filenamearty;

This item has no description.

function splitrootpath(const path: filenamety): filenamearty;

This item has no description.

function mergerootpath(const segments: filenamearty): filenamety;

This item has no description.

function checkfilename(const filename,mask: filenamety; casesensitive: boolean = false): boolean; overload;

Returns True if filename matches mask, which can contain the wildcards * and ?.

function checkfilename(const filename: filenamety; const mask: filenamearty; casesensitive: boolean = false): boolean; overload;

This item has no description.

function checkfilename(const filename: filenamety; const dirstream: dirstreamty): boolean; overload;

This item has no description.

function hasmaskchars(const filename: filenamety): boolean;

This item has no description.

function issamefilename(const a,b: filenamety): boolean;

This item has no description.

function issamefilepath(const a,b: filenamety): boolean;

This item has no description.

function filename(const path: filenamety): filenamety;

This item has no description.

function filedir(const path: filenamety): filenamety;

This item has no description.

function filenamebase(const path: filenamety): filenamety;

This item has no description.

function fileext(const path: filenamety): filenamety;

This item has no description.

function removefileext(const path: filenamety): filenamety;

This item has no description.

function hasfileext(const path: filenamety): boolean;

This item has no description.

function checkfileext(const path: filenamety; const extensions: array of filenamety): boolean;

Returns True if path has one of the given extensions (without the leading dot; case sensitivity depends on the file system), as in the following example, which detects an MSEIDE project file.

uses
  sysutils,
  msefileutils,
  msetypes,
  msesys; { fileinfoty }

var
  lfilename: filenamety;
  ldatetime: tdatetime;
  lfiles: filenamearty;
  lfileinfo: fileinfoty;

begin
  lfiles := searchfiles('demo*', '.');
  for lfilename in lfiles do
  begin
    writeln(lfilename);

    ldatetime := getfilemodtime(lfilename);
    writeln('Last modification: ', datetimetostr(ldatetime));

    if getfileinfo(lfilename, lfileinfo) then
      if fis_extinfo1valid in lfileinfo.state then
        writeln('Size: ', lfileinfo.extinfo1.size, ' bytes');

    if checkfileext(lfilename, ['prj']) then
      writeln('MSEide project');
  end;
end.

function replacefileext(const path,newext: filenamety): filenamety;

This item has no description.

function tomsefilepath(const path: filenamety; const quoted: boolean = false): filenamety;

This item has no description.

procedure tomsefilepath1(var path: filenamety; const quoted: boolean = false);

This item has no description.

function tosysfilepath(const path: filenamety; const quoted: boolean = false): filenamety;

Converts path from MSEgui's unified filepath style to the current OS's native style (tomsefilepath/tomsefilepath1 do the reverse conversion).

function tosysfilepath(const path: filenamearty; const quoted: boolean = false): filenamearty;

This item has no description.

procedure tosysfilepath1(var path: filenamety; const quoted: boolean = false);

This item has no description.

function searchfile(const filename: filenamety; dir: boolean = false; const aoptions: dirstreamoptionsty = []): filenamety; overload;

Returns the root path if the file exists, or an empty string otherwise.

function searchfile(const afilename: filenamety; const adirnames: array of filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamety; overload;

This item has no description.

function searchfile(const afilename: filenamety; const adirname: filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamety; overload;

Returns the directory of the last occurrence of afilename found in adirnames, or an empty string if none. afilename can be a path and can contain the wildcards ? and *; adirnames can contain ?, *, ** (1 to x directory levels) and *** (0 to x directory levels).

function searchfiles(const afilename: filenamety; const adirnames: array of filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamearty; overload;

Returns the directory, or an empty string if none. afilename must be a simple filename and can contain the wildcards ? and *; adirname can contain ?, *, ** and ***, as in searchfile.

function searchfiles(const afilename: filenamety; const adirname: filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamearty; overload;

Returns the paths of the files matching afilename found in adirname. afilename must be a simple filename, or a quoted list of simple filenames, and can contain the wildcards ? and *.

uses
  sysutils,
  msefileutils,
  msetypes,
  msesys; { fileinfoty }

var
  lfilename: filenamety;
  ldatetime: tdatetime;
  lfiles: filenamearty;
  lfileinfo: fileinfoty;

begin
  lfiles := searchfiles('demo*', '.');
  for lfilename in lfiles do
  begin
    writeln(lfilename);

    ldatetime := getfilemodtime(lfilename);
    writeln('Last modification: ', datetimetostr(ldatetime));

    if getfileinfo(lfilename, lfileinfo) then
      if fis_extinfo1valid in lfileinfo.state then
        writeln('Size: ', lfileinfo.extinfo1.size, ' bytes');

    if checkfileext(lfilename, ['prj']) then
      writeln('MSEide project');
  end;
end.

function searchfilenames(const afilename: filenamety; const adirname: filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []; const aoptions: dirstreamoptionsty = []): filenamearty;

Returns the file names (not the full paths, unlike searchfiles) matching afilename found in adirname. afilename must be a simple filename, or a quoted list of simple filenames, and can contain the wildcards ? and *; an empty afilename matches everything.

function dirhasentries(const adirname: filenamety; const ainclude: fileattributesty = [fa_all]; const aexclude: fileattributesty = []): boolean;

This item has no description.

function findfile(filename: filenamety; const dirnames: array of filenamety; var path: filenamety): boolean; overload;

Searches filename in dirnames and returns True if found; path is left unchanged if the file is not found.

function findfile(filename: filenamety; var path: filenamety): boolean; overload;

Searches filename and returns True if found; path is left unchanged if the file is not found.

function findfile(const filename: filenamety; const dirnames: array of filenamety): boolean; overload;

This item has no description.

function findfile(const filename: filenamety): boolean; overload;

This item has no description.

function finddir(const filename: filenamety): boolean;

This item has no description.

function findfileordir(const filename: filenamety): boolean;

This item has no description.

function uniquefilename(const path: filenamety): filenamety;

Returns a file name derived from path that does not already exist, adding a number if necessary.

function isrootpath(const path: filenamety): boolean;

This item has no description.

function copyfile(const oldfile,newfile: filenamety; const canoverwrite: boolean = true): boolean;

Copies oldfile to newfile and returns True on success; returns False if newfile already exists and canoverwrite is False.

function trycopyfile(const oldfile,newfile: filenamety; const canoverwrite: boolean = true): boolean;

Like copyfile, but returns False instead of raising an exception on error (or if newfile already exists and canoverwrite is False).

function renamefile(const oldname,newname: filenamety; const canoverwrite: boolean = true): boolean;

Renames oldname to newname and returns False if newname already exists and canoverwrite is False.

function deletefile(const filename: filenamety): boolean;

Deletes filename and returns False if it does not exist.

function trydeletefile(const filename: filenamety): boolean;

Like deletefile, but returns False instead of raising an exception if filename does not exist or could not be deleted.

procedure createdir(const path: filenamety; const rights: filerightsty = defaultdirrights);

This item has no description.

procedure createdirpath(const path: filenamety; const rights: filerightsty = defaultdirrights);

This item has no description.

function deletedir(const path: filenamety): boolean;

Deletes path and its contents recursively, and returns False if it does not exist.

function trydeletedir(const path: filenamety): boolean;

Like deletedir, but returns False instead of raising an exception if path does not exist or could not be deleted.

function getcurrentdir: filenamety; deprecated;

Warning: this symbol is deprecated.

This item has no description.

function getcurrentdirmse: filenamety;

This item has no description.

function setcurrentdir(const path: filenamety): filenamety; deprecated;

Warning: this symbol is deprecated.

This item has no description.

function setcurrentdirmse(const path: filenamety): filenamety;

This item has no description.

function trysetcurrentdirmse(const path: filenamety): boolean; overload;

This item has no description.

function trysetcurrentdirmse(const path: filenamety; out pathbefore: msestring): boolean; overload;

This item has no description.

procedure clearfileinfo(var info: fileinfoty);

This item has no description.

procedure initdirfileinfo(var info: fileinfoty; const aname: filenamety; open: boolean = false);

This item has no description.

function getfileinfo(const path: filenamety; var info: fileinfoty): boolean;

Fills info with information about the file or directory at path — such as its size, available through info.extinfo1.size — and returns False if it does not exist, as in the following example. The returned file times are in the system's native representation — normally UTC on Linux and local time on Windows; use sys_utctolocaltime/sys_localtimetoutc to convert.

uses
  sysutils,
  msefileutils,
  msetypes,
  msesys; { fileinfoty }

var
  lfilename: filenamety;
  ldatetime: tdatetime;
  lfiles: filenamearty;
  lfileinfo: fileinfoty;

begin
  lfiles := searchfiles('demo*', '.');
  for lfilename in lfiles do
  begin
    writeln(lfilename);

    ldatetime := getfilemodtime(lfilename);
    writeln('Last modification: ', datetimetostr(ldatetime));

    if getfileinfo(lfilename, lfileinfo) then
      if fis_extinfo1valid in lfileinfo.state then
        writeln('Size: ', lfileinfo.extinfo1.size, ' bytes');

    if checkfileext(lfilename, ['prj']) then
      writeln('MSEide project');
  end;
end.

function getfilemodtime(const path: filenamety): tdatetime;

Returns the last modification date and time of the file at path, or an empty date if it does not exist, as in the following example.

uses
  sysutils,
  msefileutils,
  msetypes,
  msesys; { fileinfoty }

var
  lfilename: filenamety;
  ldatetime: tdatetime;
  lfiles: filenamearty;
  lfileinfo: fileinfoty;

begin
  lfiles := searchfiles('demo*', '.');
  for lfilename in lfiles do
  begin
    writeln(lfilename);

    ldatetime := getfilemodtime(lfilename);
    writeln('Last modification: ', datetimetostr(ldatetime));

    if getfileinfo(lfilename, lfileinfo) then
      if fis_extinfo1valid in lfileinfo.state then
        writeln('Size: ', lfileinfo.extinfo1.size, ' bytes');

    if checkfileext(lfilename, ['prj']) then
      writeln('MSEide project');
  end;
end.

function filesystemiscaseinsensitive: boolean;

This item has no description.

function compfileinfos(const info1,info2: fileinfoty): filechangesty;

This item has no description.

function compfiletime(const a,b: tdatetime): integer;

Compares two date/time values and returns -1 if a is earlier than b, 0 if they are equal, or 1 if a is later than b.

function intermediatefilename(const aname: filenamety): filenamety;

This item has no description.

function msegettempdir: filenamety;

This item has no description.

function msegettempfilename(const aname: filenamety): filenamety;

This item has no description.

Types

filelistoptionty = (...);

This item has no description.

Values
  • flo_sortname
  • flo_sorttime
  • flo_sortsize
  • flo_sorttype
  • flo_casesensitive
  • flo_downsort
filelistoptionsty = set of filelistoptionty;

This item has no description.

filekindty = (...);

This item has no description.

Values
  • fk_default
  • fk_file
  • fk_dir
filechangety = (...);

This item has no description.

Values
  • fc_name
  • fc_attributes
  • fc_modtime
  • fc_accesstime
  • fc_ctime
  • fc_size
  • fc_removed
  • fc_direntries
  • fc_force
filechangesty = set of filechangety;

This item has no description.

checkfileeventty = procedure (const sender: tobject; const streaminfo: dirstreaminfoty; const fileinfo: fileinfoty; var accept: boolean) of object;

This item has no description.

pathrelocateoptionty = (...);

This item has no description.

Values
  • pro_preferenew
  • pro_onlynew
  • pro_rootpath
pathrelocateoptionsty = set of pathrelocateoptionty;

This item has no description.

filesortfuncty = function(const l,r: fileinfoty): integer of object;

This item has no description.

Constants

sortflags: filelistoptionsty = [flo_sortname,flo_sorttime,flo_sortsize];

This item has no description.

intermediatefileextension = '.tmp';

This item has no description.


Generated by PasDoc 1.0.4.