|
From: Andreas R. <and...@us...> - 2002-05-05 17:18:06
|
Update of /cvsroot/squeak/squeak/platforms/win32/plugins/FilePlugin
In directory usw-pr-cvs1:/tmp/cvs-serv28838/plugins/FilePlugin
Modified Files:
sqWin32FilePrims.c
Log Message:
added large file support
Index: sqWin32FilePrims.c
===================================================================
RCS file: /cvsroot/squeak/squeak/platforms/win32/plugins/FilePlugin/sqWin32FilePrims.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** sqWin32FilePrims.c 4 May 2002 23:20:27 -0000 1.4
--- sqWin32FilePrims.c 5 May 2002 17:18:02 -0000 1.5
***************
*** 49,53 ****
/*** Variables ***/
int thisSession = 0;
! extern unsigned char *memory;
int sqFileThisSession(void) {
--- 49,62 ----
/*** Variables ***/
int thisSession = 0;
! //extern unsigned char *memory;
!
! typedef union {
! struct {
! DWORD dwLow;
! DWORD dwHigh;
! };
! squeakFileOffsetType offset;
! } win32FileOffset;
!
int sqFileThisSession(void) {
***************
*** 56,63 ****
int sqFileAtEnd(SQFile *f) {
/* Return true if the file's read/write head is at the end of the file. */
if (!sqFileValid(f)) return success(false);
! return
! SetFilePointer(FILE_HANDLE(f), 0, NULL, FILE_CURRENT) == (DWORD) f->fileSize;
}
--- 65,74 ----
int sqFileAtEnd(SQFile *f) {
+ win32FileOffset ofs;
/* Return true if the file's read/write head is at the end of the file. */
if (!sqFileValid(f)) return success(false);
! ofs.offset = 0;
! ofs.dwLow = SetFilePointer(FILE_HANDLE(f), 0, &ofs.dwHigh, FILE_CURRENT);
! return ofs.offset == f->fileSize;
}
***************
*** 87,98 ****
}
! int sqFileGetPosition(SQFile *f) {
/* Return the current position of the file's read/write head. */
-
- DWORD position;
-
if (!sqFileValid(f)) return success(false);
! position = SetFilePointer(FILE_HANDLE(f), 0, NULL, FILE_CURRENT);
! return (int) position;
}
--- 98,108 ----
}
! squeakFileOffsetType sqFileGetPosition(SQFile *f) {
! win32FileOffset ofs;
/* Return the current position of the file's read/write head. */
if (!sqFileValid(f)) return success(false);
! ofs.offset = 0;
! ofs.dwLow = SetFilePointer(FILE_HANDLE(f), 0, &ofs.dwHigh, FILE_CURRENT);
! return ofs.offset;
}
***************
*** 133,140 ****
return success(false);
} else {
f->sessionID = thisSession;
FILE_HANDLE(f) = h;
/* compute and cache file size */
! f->fileSize = SetFilePointer(h, 0, NULL, FILE_END);
SetFilePointer(h, 0, NULL, FILE_BEGIN);
f->writable = writeFlag ? true : false;
--- 143,153 ----
return success(false);
} else {
+ win32FileOffset ofs;
f->sessionID = thisSession;
FILE_HANDLE(f) = h;
/* compute and cache file size */
! ofs.offset = 0;
! ofs.dwLow = SetFilePointer(h, 0, &ofs.dwHigh, FILE_END);
! f->fileSize = ofs.offset;
SetFilePointer(h, 0, NULL, FILE_BEGIN);
f->writable = writeFlag ? true : false;
***************
*** 143,147 ****
}
! int sqFileReadIntoAt(SQFile *f, int count, int byteArrayIndex, int startIndex) {
/* Read count bytes from the given file into byteArray starting at
startIndex. byteArray is the address of the first byte of a
--- 156,160 ----
}
! size_t sqFileReadIntoAt(SQFile *f, size_t count, int byteArrayIndex, size_t startIndex) {
/* Read count bytes from the given file into byteArray starting at
startIndex. byteArray is the address of the first byte of a
***************
*** 167,179 ****
}
! int sqFileSetPosition(SQFile *f, int position)
{
/* Set the file's read/write head to the given position. */
if (!sqFileValid(f)) return success(false);
! SetFilePointer(FILE_HANDLE(f), position, NULL, FILE_BEGIN);
return 1;
}
! int sqFileSize(SQFile *f) {
/* Return the length of the given file. */
--- 180,194 ----
}
! int sqFileSetPosition(SQFile *f, squeakFileOffsetType position)
{
+ win32FileOffset ofs;
+ ofs.offset = position;
/* Set the file's read/write head to the given position. */
if (!sqFileValid(f)) return success(false);
! SetFilePointer(FILE_HANDLE(f), ofs.dwLow, &ofs.dwHigh, FILE_BEGIN);
return 1;
}
! squeakFileOffsetType sqFileSize(SQFile *f) {
/* Return the length of the given file. */
***************
*** 189,195 ****
}
! int sqFileTruncate(SQFile *f, int offset) {
if (!sqFileValid(f)) return success(false);
! SetFilePointer(FILE_HANDLE(f), offset, NULL, FILE_BEGIN);
if(!SetEndOfFile(FILE_HANDLE(f))) return 0;
return 1;
--- 204,212 ----
}
! int sqFileTruncate(SQFile *f, squeakFileOffsetType offset) {
! win32FileOffset ofs;
! ofs.offset = offset;
if (!sqFileValid(f)) return success(false);
! SetFilePointer(FILE_HANDLE(f), ofs.dwLow, &ofs.dwHigh, FILE_BEGIN);
if(!SetEndOfFile(FILE_HANDLE(f))) return 0;
return 1;
***************
*** 203,207 ****
}
! int sqFileWriteFromAt(SQFile *f, int count, int byteArrayIndex, int startIndex) {
/* Write count bytes to the given writable file starting at startIndex
in the given byteArray. (See comment in sqFileReadIntoAt for interpretation
--- 220,224 ----
}
! size_t sqFileWriteFromAt(SQFile *f, size_t count, int byteArrayIndex, size_t startIndex) {
/* Write count bytes to the given writable file starting at startIndex
in the given byteArray. (See comment in sqFileReadIntoAt for interpretation
***************
*** 209,217 ****
*/
DWORD dwReallyWritten;
if (!(sqFileValid(f) && f->writable)) return success(false);
WriteFile(FILE_HANDLE(f), (LPVOID) (byteArrayIndex + startIndex), count, &dwReallyWritten, NULL);
/* update file size */
! f->fileSize = GetFileSize(FILE_HANDLE(f), NULL);
if ((int)dwReallyWritten != count) {
--- 226,237 ----
*/
DWORD dwReallyWritten;
+ win32FileOffset ofs;
if (!(sqFileValid(f) && f->writable)) return success(false);
WriteFile(FILE_HANDLE(f), (LPVOID) (byteArrayIndex + startIndex), count, &dwReallyWritten, NULL);
/* update file size */
! ofs.offset = 0;
! ofs.dwLow = GetFileSize(FILE_HANDLE(f), &ofs.dwHigh);
! f->fileSize = ofs.offset;
if ((int)dwReallyWritten != count) {
|