Skip to content

Commit

Permalink
FileAttributesPlugin 2.0.0: Fixes UTF8 on Windows
Browse files Browse the repository at this point in the history
Restructure FileAttributesPlugin to move platform specific functionality
out to separate files. This is required as Windows requires the "wide"
versions of posix functions to be used, e.g. access() vs. _waccess(),
while other seem to require the Windows native functions, e.g. iterating
over directories, and interleaving #ifdef _WIN32 was becoming unwieldy.
  • Loading branch information
akgrant committed Oct 2, 2018
1 parent 3cf4474 commit 0c08668
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 69 deletions.
2 changes: 0 additions & 2 deletions platforms/unix/plugins/FileAttributesPlugin/faSupport.c
Expand Up @@ -476,8 +476,6 @@ char targetFile[FA_PATH_MAX];
*/
sqInt faExists(fapath *aFaPath)
{
int status;

if (access(faGetPlatPath(aFaPath), F_OK))
return interpreterProxy->falseObject();
else
Expand Down
75 changes: 8 additions & 67 deletions src/plugins/FileAttributesPlugin/FileAttributesPlugin.c
@@ -1,9 +1,9 @@
/* Automatically generated by
VMPluginCodeGenerator VMMaker.oscog-eem.2430 uuid: 4966a4b7-293a-4911-8f2d-396a7b97d82a
VMPluginCodeGenerator VMMaker.oscog-eem.2445 uuid: ecf80f10-9e24-4ff5-8a41-d65cb2690c94
from
FileAttributesPlugin * FileAttributesPlugin.oscog-AlistairGrant.36 uuid: eb4e9dcc-d749-4b64-820b-b7fb8e9d9991
FileAttributesPlugin FileAttributesPlugin.oscog-AlistairGrant.38 uuid: f0fcdb0f-e642-4f87-8a9f-d35ffa0d05ff
*/
static char __buildInfo[] = "FileAttributesPlugin * FileAttributesPlugin.oscog-AlistairGrant.36 uuid: eb4e9dcc-d749-4b64-820b-b7fb8e9d9991 " __DATE__ ;
static char __buildInfo[] = "FileAttributesPlugin FileAttributesPlugin.oscog-AlistairGrant.38 uuid: f0fcdb0f-e642-4f87-8a9f-d35ffa0d05ff " __DATE__ ;



Expand Down Expand Up @@ -94,8 +94,6 @@ EXPORT(sqInt) primitiveStToPlatPath(void);
EXPORT(sqInt) primitiveSymlinkChangeOwner(void);
EXPORT(sqInt) primitiveVersionString(void);
static sqInt processDirectory(fapath *faPath);
static sqInt putLStatForintoBuffertargetName(char *cPathName, faStatStruct *statBufPointer, sqInt *fileNameOop);
static sqInt putStatForintoBuffertargetName(char *cPathName, faStatStruct *statBufPointer, sqInt *fileNameOop);
static sqInt readLinkintomaxLength(char *cPathName, char *cLinkPtr, size_t maxLength);
EXPORT(sqInt) setInterpreter(struct VirtualMachine*anInterpreter);
static sqInt squeakPathtoPlatformmaxLen(sqInt pathOop, char *cPathString, sqInt maxLength);
Expand Down Expand Up @@ -179,9 +177,9 @@ extern
struct VirtualMachine* interpreterProxy;
static const char *moduleName =
#ifdef SQUEAK_BUILTIN_PLUGIN
"FileAttributesPlugin * FileAttributesPlugin.oscog-AlistairGrant.36 (i)"
"FileAttributesPlugin FileAttributesPlugin.oscog-AlistairGrant.38 (i)"
#else
"FileAttributesPlugin * FileAttributesPlugin.oscog-AlistairGrant.36 (e)"
"FileAttributesPlugin FileAttributesPlugin.oscog-AlistairGrant.38 (e)"
#endif
;
static void * sCLPfn;
Expand Down Expand Up @@ -503,7 +501,7 @@ primitiveChangeMode(void)
EXPORT(sqInt)
primitiveChangeOwner(void)
{
char cString[PATH_MAX+1];
char cString[FA_PATH_MAX];
sqInt fileNameOop;
sqInt groupId;
sqInt ownerId;
Expand All @@ -518,7 +516,7 @@ primitiveChangeOwner(void)
}

# if HAVE_CHOWN
squeakPathtoPlatformmaxLen(fileNameOop, cString, PATH_MAX);
squeakPathtoPlatformmaxLen(fileNameOop, cString, FA_PATH_MAX);
if (failed()) {
return primitiveFailForOSError(primitiveFailureCode());
}
Expand Down Expand Up @@ -978,7 +976,7 @@ primitiveSymlinkChangeOwner(void)
EXPORT(sqInt)
primitiveVersionString(void)
{
popthenPush(1, stringFromCString("1.4.0d10"));
popthenPush(1, stringFromCString("2.0.0"));
return 0;
}

Expand Down Expand Up @@ -1026,63 +1024,6 @@ processDirectory(fapath *faPath)
}


/* Call stat() on cPathName, storing the results in
the buffer at statBufPointer. */

/* FileAttributesPlugin>>#putLStatFor:intoBuffer:targetName: */
static sqInt
putLStatForintoBuffertargetName(char *cPathName, faStatStruct *statBufPointer, sqInt *fileNameOop)
{
char cLinkName[PATH_MAX];
sqInt len;
sqInt status;


# if HAVE_LSTAT == 1
status = lstat(cPathName, statBufPointer);
if (status != 0) {
/* begin cantStatPath */
return -3;
}
if ((S_ISLNK(statBufPointer->st_mode)) == 0) {
fileNameOop[0] = (nilObject());
}
else {
len = readLinkintomaxLength(cPathName, cLinkName, PATH_MAX);
if (len < 0) {
return len;
}
status = faCharToByteArray(cLinkName, fileNameOop);
}
# else /* HAVE_LSTAT == 1 */

/* #HAVE_LSTAT = 1 */
/* begin invalidRequest */
status = -11;
# endif /* HAVE_LSTAT == 1 */
return status;
}


/* Call stat() on cPathName, storing the results in
the buffer at statBufPointer. */

/* FileAttributesPlugin>>#putStatFor:intoBuffer:targetName: */
static sqInt
putStatForintoBuffertargetName(char *cPathName, faStatStruct *statBufPointer, sqInt *fileNameOop)
{
sqInt status;

status = stat(cPathName, statBufPointer);
if (status != 0) {
/* begin cantStatPath */
return -3;
}
fileNameOop[0] = (nilObject());
return 0;
}


/* Get the target filename of the supplied symbolic link. */

/* FileAttributesPlugin>>#readLink:into:maxLength: */
Expand Down

0 comments on commit 0c08668

Please sign in to comment.