unit uCheck;
interface
uses StrUtils, SysUtils;
type
TFileDirExistsRet =
set of (fdeFile, fdeDir, fdeShortDir, fdeLW, fdeUNC);
function FileDirExists(
const FileOrDir :
string ) : TFileDirExistsRet;
function HasExtension(
const Filename :
string) : Boolean;
implementation
function HasExtension(
const Filename :
string) : Boolean;
begin
if ExtractFileExt(Filename)<>'
'
then Result:=true
else Result := false;
end;
function IsUNCPath(
const Filename :
string) : Boolean;
begin
if Copy(Filename,1,2)='
\\'
then Result:=true
else Result := false;
end;
function FileDirExists(
const FileOrDir :
string ) : TFileDirExistsRet;
var
Path :
String;
begin
Result:=[];
Path:=ExtractFilePath(FileOrDir);
if FileExists(FileOrDir)
then
Result:=[fdeFile, fdeDir, fdeShortDir, fdeLW]
else
begin
if HasExtension(FileOrDir)
then
begin
if DirectoryExists(Path)
then
Result:=[fdeDir, fdeShortDir, fdeLW]
else
begin
if DirectoryExists(ExtractFilepath(Path))
then
Result:=[fdeShortDir, fdeLW]
else
begin
if DirectoryExists(ExtractFileDrive(FileOrDir))
then
Result:=[fdeLW]
end;
end
end
else
begin
if DirectoryExists(FileOrDir)
then
Result:=[fdeDir, fdeShortDir, fdeLW]
else
begin
if DirectoryExists(Path)
then
Result:=[fdeShortDir, fdeLW]
else
begin
if DirectoryExists(ExtractFileDrive(FileOrDir))
then
Result:=[fdeLW]
end;
end
end
end;
//Festetllen ob UNC-Pfad
if IsUNCPath(FileOrDir)
then
Result:=Result+[fdeUNC]
end;
end.