Revision [163]

This is an old revision of sqGetFilenameFromString made by JohnMcIntosh on 2008-10-16 20:37:07.

 

sqInt sqGetFilenameFromString(char * aCharBuffer, char * aFilenameString, sqInt filenameLength, sqInt resolveAlias)


Parms:
aCharBuffer location to put encoded C string.
aFilenameString location of the squeak encoded byte string containing the file name
filenameLength length of the file name in aFilenameString
resolveAlias. True if we should resolve any alias file information

return: NONE, fake return of zero
From: Interpreter, file plugin
Why: To decode squeak file name to platform encoding and resolve aliases
Responsibility:
Typically take the file/path bytes and convert from the image character encoding to the platform encoding
On the macintosh and unix systems if resolveAlias is TRUE we must resolve the path/file name as a possible alias (symbolic link, or other form).

For example
sqFileDeleteNameSize, sqFileRenameOldSizeNewSize both say not to resolve the alias because we want to delete or rename the alias file
not the target.

sqFileOpen does call with true to resolve the alias because we want to open the target of the alias file, not the alias file.
Note that on unix opening a symbolic link would open the target of the symbolic link, but on os-9/os-x opening an alias file does not imply opening the target of the alias file.


MacIntosh
os-9/OSXCarbon
Note the issues with os-9 alias files, which are files that contain location information about where to find the actual file. The target file could be on any attached volume, or on a remote appleshare server. This file type is different than hard or soft linked unix files. When using unix calls we need to beware of wanting to delete say the target of the alias file, or do we want to delete the alias file.

Bugs: multiple macintosh finder alias files in a path, require decomposing the path and traversing level by level resolving the path incrementally since the API calls are not able to solve such complexity (NOTE need to retest with current OSX)

Cocoa:
TBD

iPhone
Only supports UTF8 file names
Does not support os-9 alias files

Unix
Invoke sq2uxPath to get unix platform encoding, then if resolveAlias attempt to resolve to the actual path if the path points to an symbolic link.
If Darwin then attempt to resolve any os-9 alias files.

Bugs: multiple os-9 alias file indirections in the path cause failure.
Windows
Ignore alias flag, just copy the file name into the target buffer.
No translation occurs.
? Unclear if the file name path has to be translated, or is it translated at each point where it is used by the operating system api?

BUGS
BUGS possible buffer overflow because length is implied to be 1000 and not guarded by caller.
BUGS calls just assume it works, but it could fail if name with null > 1000 or if encoding/decoding fails.

There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki