Skip to content

Commit

Permalink
Use void* instead of FILE* for Win32 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
akgrant committed Mar 6, 2018
1 parent 2326965 commit 5aabffb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion platforms/Cross/plugins/FilePlugin/FilePlugin.h
Expand Up @@ -56,7 +56,7 @@ sqInt sqFileShutdown(void);
sqInt sqFileOpen(SQFile *f, char *sqFileName, sqInt sqFileNameSize, sqInt writeFlag);
sqInt sqFileOpenNew(SQFile *f, char *sqFileName, sqInt sqFileNameSize, sqInt *exists);
sqInt sqConnectToFileDescriptor(SQFile *f, int fd, sqInt writeFlag);
sqInt sqConnectToFile(SQFile *f, FILE *inFile, sqInt writeFlag);
sqInt sqConnectToFile(SQFile *f, void *file, sqInt writeFlag);
size_t sqFileReadIntoAt(SQFile *f, size_t count, char *byteArrayIndex, size_t startIndex);
sqInt sqFileRenameOldSizeNewSize(char *sqOldName, sqInt sqOldNameSize, char *sqNewName, sqInt sqNewNameSize);
sqInt sqFileSetPosition(SQFile *f, squeakFileOffsetType position);
Expand Down
4 changes: 2 additions & 2 deletions platforms/Cross/plugins/FilePlugin/sqFilePluginBasicPrims.c
Expand Up @@ -491,11 +491,11 @@ sqConnectToFileDescriptor(SQFile *sqFile, int fd, sqInt writeFlag)
FILE *file = openFileDescriptor(fd, writeFlag ? "wb" : "rb");
if (!file)
return interpreterProxy->success(false);
return sqConnectToFile(sqFile, file, writeFlag);
return sqConnectToFile(sqFile, (void *)file, writeFlag);
}

sqInt
sqConnectToFile(SQFile *sqFile, FILE *file, sqInt writeFlag)
sqConnectToFile(SQFile *sqFile, void *file, sqInt writeFlag)
{
/*
* Populate the supplied SQFile structure with the supplied FILE.
Expand Down
11 changes: 6 additions & 5 deletions platforms/win32/plugins/FilePlugin/sqWin32FilePrims.c
Expand Up @@ -262,25 +262,26 @@ sqConnectToFileDescriptor(SQFile *sqFile, int fd, sqInt writeFlag)
* Smalltalk is reponsible for handling character encoding and
* line ends.
*/
FILE *file = _fdopen(fd, writeFlag ? "wb" : "rb");
HANDLE file = _fdopen(fd, writeFlag ? "wb" : "rb");
if (!file)
return interpreterProxy->success(false);
return sqConnectToFile(sqFile, file, writeFlag);
}

sqInt
sqConnectToFile(SQFile *sqFile, FILE *file, sqInt writeFlag)
sqConnectToFile(SQFile *sqFile, void *file, sqInt writeFlag)
{
/*
* Populate the supplied SQFile structure with the supplied FILE.
*
* writeFlag indicates whether the file is read-only or writable
* and must be compatible with the existing access.
*/
setFile(sqFile, file);
setSize(sqFile, 0);
sqFile->file = (HANDLE)file;
AddHandleToTable(win32Files, file);
/* setSize(sqFile, 0); */
sqFile->sessionID = thisSession;
sqFile->lastOp = UNCOMMITTED;
sqFile->lastOp = 0; /* Unused on Win32 */
sqFile->writable = writeFlag;
return 1;
}
Expand Down

0 comments on commit 5aabffb

Please sign in to comment.