[Vm-dev] [commit][2953] In sqFileOpen()
ensure that Mac file characteristics are set only when a new file is created
commits at squeakvm.org
commits at squeakvm.org
Fri Jun 6 23:36:47 UTC 2014
Revision: 2953
Author: lewis
Date: 2014-06-06 16:36:45 -0700 (Fri, 06 Jun 2014)
Log Message:
-----------
In sqFileOpen() ensure that Mac file characteristics are set only when a new file is created
Modified Paths:
--------------
trunk/platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c
Modified: trunk/platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c
===================================================================
--- trunk/platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c 2014-06-06 22:37:22 UTC (rev 2952)
+++ trunk/platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c 2014-06-06 23:36:45 UTC (rev 2953)
@@ -251,10 +251,21 @@
if (getFile(f) == NULL)
setFile(f, fopen(cFileName, "ab"));
if (getFile(f) != NULL) {
+ /* New file created, set Mac file characteristics */
char type[4],creator[4];
dir_GetMacFileTypeAndCreator(sqFileName, sqFileNameSize, type, creator);
if (strncmp(type,"BINA",4) == 0 || strncmp(type,"????",4) == 0 || *(int *)type == 0 )
dir_SetMacFileTypeAndCreator(sqFileName, sqFileNameSize,"TEXT","R*ch");
+ } else {
+ /* If the file could not be opened read/write and if a new file
+ could not be created, then it may be that the file exists but
+ does not permit read access. Try opening as a write only file,
+ opened for append to preserve existing file contents.
+ */
+ setFile(f, fopen(cFileName, "ab"));
+ if (getFile(f) == NULL) {
+ return interpreterProxy->success(false);
+ }
}
}
f->writable = true;
More information about the Vm-dev
mailing list