diff --git a/include/common_types.h b/include/common_types.h index e16ee70..3df3894 100644 --- a/include/common_types.h +++ b/include/common_types.h @@ -72,11 +72,11 @@ extern "C" typedef unsigned short mode_t; typedef short nlink_t; //using our own "type" to make sure we can get as much of the filesize as possible..and workaround Windows issues with off_t -TJE - typedef int64_t offset_t;//NOTE: WinAPI uses __int64_t which is the same as long long which is also what int64_t from stdint.h is defined as + typedef int64_t oscoffset_t;//NOTE: WinAPI uses __int64_t which is the same as long long which is also what int64_t from stdint.h is defined as typedef unsigned long winsyserror_t; #else //using our own "type" to make sure we can get as much of the filesize as possible..and workaround Windows issues with off_t -TJE - typedef off_t offset_t;//to deal with windows differences in off_t definitions in stat + typedef off_t oscoffset_t;//to deal with windows differences in off_t definitions in stat #endif #if !defined (HAVE_C11_ANNEX_K) && !defined(__STDC_SECURE_LIB__) diff --git a/include/secure_file.h b/include/secure_file.h index 4ea1172..549d784 100644 --- a/include/secure_file.h +++ b/include/secure_file.h @@ -105,7 +105,7 @@ extern "C" uid_t userID; gid_t groupID; dev_t representedDeviceID; - offset_t filesize; + oscoffset_t filesize; int64_t fileLastAccessTime;//milliseconds since Unix epoch (in Windows, converted from Windows file epoch to this value) int64_t fileModificationTime;//milliseconds since Unix epoch (in Windows, converted from Windows file epoch to this value) int64_t fileStatusChangeTime;//milliseconds since Unix epoch (in Windows, converted from Windows file epoch to this value) @@ -201,9 +201,9 @@ extern "C" M_NODISCARD eSecureFileError secure_Read_File(secureFileInfo* M_RESTRICT fileInfo, void* M_RESTRICT buffer, size_t buffersize, size_t elementsize, size_t count, size_t* numberread/*optional*/); M_NODISCARD eSecureFileError secure_Write_File(secureFileInfo* M_RESTRICT fileInfo, void* M_RESTRICT buffer, size_t buffersize, size_t elementsize, size_t count, size_t* numberwritten/*optional*/); - M_NODISCARD eSecureFileError secure_Seek_File(secureFileInfo* fileInfo, offset_t offset, int initialPosition); + M_NODISCARD eSecureFileError secure_Seek_File(secureFileInfo* fileInfo, oscoffset_t offset, int initialPosition); M_NODISCARD eSecureFileError secure_Rewind_File(secureFileInfo* fileInfo); - M_NODISCARD offset_t secure_Tell_File(secureFileInfo* fileInfo); + M_NODISCARD oscoffset_t secure_Tell_File(secureFileInfo* fileInfo); //This function will unlink the file if it is still open, otherwise it will remove it. M_NODISCARD eSecureFileError secure_Remove_File(secureFileInfo* fileInfo); diff --git a/src/secure_file.c b/src/secure_file.c index 59a6ee8..11eac5d 100644 --- a/src/secure_file.c +++ b/src/secure_file.c @@ -715,7 +715,7 @@ M_NODISCARD eSecureFileError secure_Write_File(secureFileInfo* M_RESTRICT fileIn return SEC_FILE_INVALID_SECURE_FILE; } -M_NODISCARD eSecureFileError secure_Seek_File(secureFileInfo* fileInfo, offset_t offset, int initialPosition) +M_NODISCARD eSecureFileError secure_Seek_File(secureFileInfo* fileInfo, oscoffset_t offset, int initialPosition) { if (fileInfo) { @@ -773,7 +773,7 @@ M_NODISCARD eSecureFileError secure_Rewind_File(secureFileInfo* fileInfo) return SEC_FILE_INVALID_SECURE_FILE; } -M_NODISCARD offset_t secure_Tell_File(secureFileInfo* fileInfo) +M_NODISCARD oscoffset_t secure_Tell_File(secureFileInfo* fileInfo) { if (fileInfo) { @@ -784,7 +784,7 @@ M_NODISCARD offset_t secure_Tell_File(secureFileInfo* fileInfo) fileInfo->error = SEC_FILE_INVALID_FILE; if (fileInfo->file) { - offset_t tellres = 0; + oscoffset_t tellres = 0; //Windows has _fseeki64, which may be better to use instead for larger files or to be compatible with larger files. //Linux/posix have fseeko and ftello which use off_t which can be wider as well. (POSIX 2001) errno = 0;//ISO secure coding standard recommends this to ensure errno is interpretted correctly after this call