Skip to content

Commit

Permalink
Make recent FilePlugin changes MSVC compatible
Browse files Browse the repository at this point in the history
mode_t is not defined, it's int, and authorization flags will be different than unix
  • Loading branch information
nicolas-cellier-aka-nice committed May 28, 2017
1 parent dd5609c commit e9020ec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions platforms/Cross/plugins/FilePlugin/FilePlugin.h
Expand Up @@ -17,6 +17,10 @@

#include <sys/types.h>

#ifdef _MSC_VER
typedef int mode_t;
#endif

#include "sqMemoryAccess.h"

/* squeak file record; see sqFilePrims.c for details */
Expand Down
18 changes: 17 additions & 1 deletion platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c
Expand Up @@ -318,12 +318,16 @@ sqFileOpen(SQFile *f, char *sqFileName, sqInt sqFileNameSize, sqInt writeFlag) {
mode = "r+b";
fd = openFileWithFlagsInMode(
cFileName,
O_CREAT|O_EXCL|O_RDWR,
O_CREAT | O_EXCL | O_RDWR,
/* the mode fopen() uses when creating files;
will likely be rw-r--r-- after being modified
by the process's umask
*/
#ifdef _MSC_VER
_S_IREAD | _S_IWRITE);
#else
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
#endif
/* could have failed if we lack read permission
or it already exists
Expand All @@ -337,7 +341,11 @@ sqFileOpen(SQFile *f, char *sqFileName, sqInt sqFileNameSize, sqInt writeFlag) {
will likely be -w------- after being
modified by the process's umask
*/
#ifdef _MSC_VER
_S_IWRITE);
#else
S_IWUSR|S_IWGRP|S_IWOTH);
#endif
}

if (fd >= 0)
Expand Down Expand Up @@ -415,7 +423,11 @@ sqFileOpenNew(SQFile *f, char *sqFileName, sqInt sqFileNameSize) {
/* the mode fopen() uses when creating files; will likely
be rw-r--r-- after being modified by the process's umask
*/
#ifdef _MSC_VER
_S_IREAD | _S_IWRITE);
#else
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
#endif
/* could have failed if we lack read permission or it already exists */
if (fd < 0 && errno == EACCES) {
mode = "wb";
Expand All @@ -425,7 +437,11 @@ sqFileOpenNew(SQFile *f, char *sqFileName, sqInt sqFileNameSize) {
/* write-only version of the above mode; will likely
be -w------- after being modified by the process's umask
*/
#ifdef _MSC_VER
_S_IWRITE);
#else
S_IWUSR|S_IWGRP|S_IWOTH);
#endif
}

if (fd >= 0) {
Expand Down

0 comments on commit e9020ec

Please sign in to comment.