|
@@ -330,11 +330,12 @@ end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+
|
|
{Gives the path for a given file or directory. If parent is true,
|
|
{Gives the path for a given file or directory. If parent is true,
|
|
a path to the directory, where the file or directory is located,
|
|
a path to the directory, where the file or directory is located,
|
|
- is returned. Functioning even with System 6.
|
|
|
|
- TODO use AnsiString instead of Mac_Handle}
|
|
|
|
-function FSpGetFullPath (spec: FSSpec; var fullPathHandle: Mac_Handle;
|
|
|
|
|
|
+ is returned. Functioning even with System 6.}
|
|
|
|
+
|
|
|
|
+function FSpGetFullPath (spec: FSSpec; var fullPath: AnsiString;
|
|
parent: Boolean): OSErr;
|
|
parent: Boolean): OSErr;
|
|
|
|
|
|
var
|
|
var
|
|
@@ -342,26 +343,19 @@ function FSpGetFullPath (spec: FSSpec; var fullPathHandle: Mac_Handle;
|
|
pb: CInfoPBRec;
|
|
pb: CInfoPBRec;
|
|
|
|
|
|
begin
|
|
begin
|
|
- fullPathHandle:= NewHandle(0); { Allocate a zero-length handle }
|
|
|
|
- if fullPathHandle = nil then
|
|
|
|
- begin
|
|
|
|
- FSpGetFullPath:= MemError;
|
|
|
|
- Exit;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
|
|
+ res := noErr;
|
|
if spec.parID = fsRtParID then { The object is a volume }
|
|
if spec.parID = fsRtParID then { The object is a volume }
|
|
begin
|
|
begin
|
|
if not parent then
|
|
if not parent then
|
|
begin
|
|
begin
|
|
{ Add a colon to make it a full pathname }
|
|
{ Add a colon to make it a full pathname }
|
|
- spec.name := Concat(spec.name, ':');
|
|
|
|
-
|
|
|
|
- { We're done }
|
|
|
|
- Munger(fullPathHandle, 0, nil, 0, @spec.name[1], Length(spec.name));
|
|
|
|
- res := MemError;
|
|
|
|
|
|
+ fullPath:= spec.name + ':';
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- res := noErr;
|
|
|
|
|
|
+ begin
|
|
|
|
+ fullPath:= '';
|
|
|
|
+ res:= afpObjectTypeErr; {to have something close to this error.}
|
|
|
|
+ end;
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
@@ -369,7 +363,9 @@ begin
|
|
|
|
|
|
{ Add the object name }
|
|
{ Add the object name }
|
|
if not parent then
|
|
if not parent then
|
|
- Munger(fullPathHandle, 0, nil, 0, @spec.name[1], Length(spec.name));
|
|
|
|
|
|
+ fullPath:= spec.name
|
|
|
|
+ else
|
|
|
|
+ fullPath:= '';
|
|
|
|
|
|
{ Get the ancestor directory names }
|
|
{ Get the ancestor directory names }
|
|
pb.ioNamePtr := @spec.name;
|
|
pb.ioNamePtr := @spec.name;
|
|
@@ -385,21 +381,14 @@ begin
|
|
if res = noErr then
|
|
if res = noErr then
|
|
begin
|
|
begin
|
|
{ Append colon to directory name }
|
|
{ Append colon to directory name }
|
|
- spec.name := Concat(spec.name, ':');
|
|
|
|
|
|
+ spec.name := spec.name + ':';
|
|
{ Add directory name to fullPathHandle }
|
|
{ Add directory name to fullPathHandle }
|
|
- Munger(fullPathHandle, 0, nil, 0, @spec.name[1], Length(spec.name));
|
|
|
|
- res := MemError;
|
|
|
|
|
|
+ fullPath:= spec.name + fullPath;
|
|
end
|
|
end
|
|
end
|
|
end
|
|
until not ((res = noErr) and (pb.ioDrDirID <> fsRtDirID));
|
|
until not ((res = noErr) and (pb.ioDrDirID <> fsRtDirID));
|
|
end;
|
|
end;
|
|
|
|
|
|
- if res <> noErr then
|
|
|
|
- begin
|
|
|
|
- DisposeHandle(fullPathHandle);
|
|
|
|
- fullPathHandle:= nil;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
FSpGetFullPath := res;
|
|
FSpGetFullPath := res;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -418,22 +407,13 @@ var
|
|
err: OSErr;
|
|
err: OSErr;
|
|
res: Integer;
|
|
res: Integer;
|
|
spec: FSSpec;
|
|
spec: FSSpec;
|
|
- pathHandle: Mac_Handle;
|
|
|
|
|
|
|
|
begin
|
|
begin
|
|
res:= PathArgToFSSpec(s, spec);
|
|
res:= PathArgToFSSpec(s, spec);
|
|
if (res = 0) or (res = 2) then
|
|
if (res = 0) or (res = 2) then
|
|
begin
|
|
begin
|
|
- err:= FSpGetFullPath(spec, pathHandle, false);
|
|
|
|
- if err = noErr then
|
|
|
|
- begin
|
|
|
|
- HLock(pathHandle);
|
|
|
|
- SetString(fullpath, pathHandle^, GetHandleSize(pathHandle));
|
|
|
|
- DisposeHandle(pathHandle);
|
|
|
|
- PathArgToFullPath:= 0;
|
|
|
|
- end
|
|
|
|
- else
|
|
|
|
- PathArgToFullPath:= MacOSErr2RTEerr(err);
|
|
|
|
|
|
+ err:= FSpGetFullPath(spec, fullpath, false);
|
|
|
|
+ PathArgToFullPath:= MacOSErr2RTEerr(err);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
PathArgToFullPath:=res;
|
|
PathArgToFullPath:=res;
|