BYTE* buffer;
FILE* fp = NULL;
size_t read_size;
- long int file_size;
+ INT64 file_size;
fp = fopen(name, "r");
if (!fp)
return FALSE;
- fseek(fp, 0, SEEK_END);
- file_size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
+ _fseeki64(fp, 0, SEEK_END);
+ file_size = _ftelli64(fp);
+ _fseeki64(fp, 0, SEEK_SET);
if (file_size < 1)
{
FILE* fp;
char* name;
BOOL write;
- int file_size;
+ INT64 file_size;
int record_count;
pcap_header header;
pcap_record* head;
struct _EGFX_SAMPLE_FILE
{
BYTE* buffer;
- UINT32 size;
+ size_t size;
};
typedef struct _EGFX_SAMPLE_FILE EGFX_SAMPLE_FILE;
return 1;
}
-static BYTE* test_progressive_load_file(char* path, char* file, UINT32* size)
+static BYTE* test_progressive_load_file(char* path, char* file, size_t* size)
{
FILE* fp;
BYTE* buffer;
if (!fp)
return NULL;
- fseek(fp, 0, SEEK_END);
- *size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
+ _fseeki64(fp, 0, SEEK_END);
+ *size = _ftelli64(fp);
+ _fseeki64(fp, 0, SEEK_SET);
buffer = (BYTE*) malloc(*size);
if (!buffer)
BYTE* buffer;
FILE* fp = NULL;
size_t readSize;
- long int fileSize;
+ INT64 fileSize;
fp = fopen(name, "r");
if (!fp)
return -1;
- fseek(fp, 0, SEEK_END);
- fileSize = ftell(fp);
- fseek(fp, 0, SEEK_SET);
+ _fseeki64(fp, 0, SEEK_END);
+ fileSize = _ftelli64(fp);
+ _fseeki64(fp, 0, SEEK_SET);
if (fileSize < 1)
{
rdpRsaKey* key_new(const char* keyfile)
{
FILE* fp = NULL;
- int length;
+ INT64 length;
char* buffer = NULL;
rdpRsaKey* key = NULL;
goto out_free;
}
- if (fseek(fp, 0, SEEK_END) < 0)
+ if (_fseeki64(fp, 0, SEEK_END) < 0)
goto out_free;
- if ((length = ftell(fp)) < 0)
+ if ((length = _ftelli64(fp)) < 0)
goto out_free;
- if (fseek(fp, 0, SEEK_SET) < 0)
+ if (_fseeki64(fp, 0, SEEK_SET) < 0)
goto out_free;
buffer = (char *)malloc(length + 1);
BOOL pcap_has_next_record(rdpPcap* pcap)
{
- if (pcap->file_size - (ftell(pcap->fp)) <= 16)
+ if (pcap->file_size - (_ftelli64(pcap->fp)) <= 16)
return FALSE;
return TRUE;
}
else
{
- fseek(pcap->fp, 0, SEEK_END);
- pcap->file_size = (int) ftell(pcap->fp);
- fseek(pcap->fp, 0, SEEK_SET);
+ _fseeki64(pcap->fp, 0, SEEK_END);
+ pcap->file_size = _ftelli64(pcap->fp);
+ _fseeki64(pcap->fp, 0, SEEK_SET);
if (!pcap_read_header(pcap, &pcap->header))
goto fail;
}
if (!fp)
return NULL;
- fseek(fp, 0, SEEK_END);
- fileSize = ftell(fp);
- fseek(fp, 0, SEEK_SET);
+ _fseeki64(fp, 0, SEEK_END);
+ fileSize = _ftelli64(fp);
+ _fseeki64(fp, 0, SEEK_SET);
if (fileSize < 1)
{
#include <winpr/user.h>
+#ifndef _WIN32
+#define _fseeki64(fp, offset, origin) fseeko(fp, offset, origin)
+#define _ftelli64(fp) ftello(fp)
+#endif
+
#endif /* WINPR_WTYPES_H */
BOOL is_directory;
int fd;
- off_t offset;
- off_t size;
+ INT64 offset;
+ INT64 size;
};
static struct posix_file* make_posix_file(const char* local_name, const WCHAR* remote_name)
return FALSE;
}
-static UINT posix_file_get_size(const struct posix_file* file, off_t* size)
+static UINT posix_file_get_size(const struct posix_file* file, INT64* size)
{
struct stat statbuf;
const wClipboardFileSizeRequest* request)
{
UINT error = NO_ERROR;
- off_t size = 0;
+ INT64 size = 0;
struct posix_file* file = NULL;
if (!delegate || !delegate->clipboard || !request)
static BOOL FileSetEndOfFile(HANDLE hFile)
{
WINPR_FILE* pFile = (WINPR_FILE*) hFile;
- off_t size;
+ INT64 size;
if (!hFile)
return FALSE;
- size = ftell(pFile->fp);
+ size = _ftelli64(pFile->fp);
if (ftruncate(fileno(pFile->fp), size) < 0)
{
return INVALID_SET_FILE_POINTER;
}
- if (fseek(pFile->fp, offset, whence))
+ if (_fseeki64(pFile->fp, offset, whence))
{
- WLog_ERR(TAG, "fseek(%s) failed with %s [0x%08X]", pFile->lpFileName,
+ WLog_ERR(TAG, "_fseeki64(%s) failed with %s [0x%08X]", pFile->lpFileName,
strerror(errno), errno);
return INVALID_SET_FILE_POINTER;
}
- return ftell(pFile->fp);
+ return _ftelli64(pFile->fp);
}
static BOOL FileSetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod)
return FALSE;
}
- if (fseek(pFile->fp, liDistanceToMove.QuadPart, whence))
+ if (_fseeki64(pFile->fp, liDistanceToMove.QuadPart, whence))
{
- WLog_ERR(TAG, "fseek(%s) failed with %s [0x%08X]", pFile->lpFileName,
+ WLog_ERR(TAG, "_fseeki64(%s) failed with %s [0x%08X]", pFile->lpFileName,
strerror(errno), errno);
return FALSE;
}
if (lpNewFilePointer)
- lpNewFilePointer->QuadPart = ftell(pFile->fp);
+ lpNewFilePointer->QuadPart = _ftelli64(pFile->fp);
return TRUE;
}
static DWORD FileGetFileSize(HANDLE Object, LPDWORD lpFileSizeHigh)
{
WINPR_FILE* file;
- long cur, size;
+ INT64 cur, size;
if (!Object)
return 0;
file = (WINPR_FILE *)Object;
- cur = ftell(file->fp);
+ cur = _ftelli64(file->fp);
if (cur < 0)
{
- WLog_ERR(TAG, "ftell(%s) failed with %s [0x%08X]", file->lpFileName,
+ WLog_ERR(TAG, "_ftelli64(%s) failed with %s [0x%08X]", file->lpFileName,
strerror(errno), errno);
return INVALID_FILE_SIZE;
}
- if (fseek(file->fp, 0, SEEK_END) != 0)
+ if (_fseeki64(file->fp, 0, SEEK_END) != 0)
{
- WLog_ERR(TAG, "fseek(%s) failed with %s [0x%08X]", file->lpFileName,
+ WLog_ERR(TAG, "_fseeki64(%s) failed with %s [0x%08X]", file->lpFileName,
strerror(errno), errno);
return INVALID_FILE_SIZE;
}
- size = ftell(file->fp);
+ size = _ftelli64(file->fp);
if (size < 0)
{
- WLog_ERR(TAG, "ftell(%s) failed with %s [0x%08X]", file->lpFileName,
+ WLog_ERR(TAG, "_ftelli64(%s) failed with %s [0x%08X]", file->lpFileName,
strerror(errno), errno);
return INVALID_FILE_SIZE;
}
- if (fseek(file->fp, cur, SEEK_SET) != 0)
+ if (_fseeki64(file->fp, cur, SEEK_SET) != 0)
{
- WLog_ERR(TAG, "ftell(%s) failed with %s [0x%08X]", file->lpFileName,
+ WLog_ERR(TAG, "_ftelli64(%s) failed with %s [0x%08X]", file->lpFileName,
strerror(errno), errno);
return INVALID_FILE_SIZE;
}
static void reg_load_start(Reg* reg)
{
- long int file_size;
- fseek(reg->fp, 0, SEEK_END);
- file_size = ftell(reg->fp);
- fseek(reg->fp, 0, SEEK_SET);
+ INT64 file_size;
+ _fseeki64(reg->fp, 0, SEEK_END);
+ file_size = _ftelli64(reg->fp);
+ _fseeki64(reg->fp, 0, SEEK_SET);
reg->line = NULL;
reg->next_line = NULL;
reg->buffer = NULL;
static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp)
{
- long length;
+ INT64 length;
char* tzid = NULL;
- if (fseek(fp, 0, SEEK_END) != 0)
+ if (_fseeki64(fp, 0, SEEK_END) != 0)
return NULL;
- length = ftell(fp);
- if (fseek(fp, 0, SEEK_SET) != 0)
+ length = _ftelli64(fp);
+ if (_fseeki64(fp, 0, SEEK_SET) != 0)
return NULL;
if (length < 2)
int winpr_image_png_read_fp(wImage* image, FILE* fp)
{
- int size;
+ INT64 size;
BYTE* data;
UINT32 width;
UINT32 height;
int lodepng_status;
- fseek(fp, 0, SEEK_END);
- size = ftell(fp);
- fseek(fp, 0, SEEK_SET);
+ _fseeki64(fp, 0, SEEK_END);
+ size = _ftelli64(fp);
+ _fseeki64(fp, 0, SEEK_SET);
data = (BYTE*) malloc(size);
if (fread((void*) &bi, sizeof(WINPR_BITMAP_INFO_HEADER), 1, fp) != 1)
return -1;
- if (ftell(fp) != bf.bfOffBits)
+ if (_ftelli64(fp) != bf.bfOffBits)
{
- fseek(fp, bf.bfOffBits, SEEK_SET);
+ _fseeki64(fp, bf.bfOffBits, SEEK_SET);
}
image->width = bi.biWidth;
return -1;
}
- if (fread((void*) &sig, sizeof(sig), 1, fp) != 1 || fseek(fp, 0, SEEK_SET) < 0)
+ if (fread((void*) &sig, sizeof(sig), 1, fp) != 1 || _fseeki64(fp, 0, SEEK_SET) < 0)
{
fclose(fp);
return -1;
int IniFile_Load_File(wIniFile* ini, const char* filename)
{
- int fileSize;
+ INT64 fileSize;
if (IniFile_Open_File(ini, filename) < 0)
return -1;
- if (fseek(ini->fp, 0, SEEK_END) < 0)
+ if (_fseeki64(ini->fp, 0, SEEK_END) < 0)
goto out_file;
- fileSize = ftell(ini->fp);
+ fileSize = _ftelli64(ini->fp);
if (fileSize < 0)
goto out_file;
- if (fseek(ini->fp, 0, SEEK_SET) < 0)
+ if (_fseeki64(ini->fp, 0, SEEK_SET) < 0)
goto out_file;
ini->line = NULL;
* Modifications fixing various errors. */
#include "lodepng.h"
+#include <winpr/wtypes.h>
#include <stdio.h>
#include <stdlib.h>
unsigned lodepng_load_file(unsigned char** out, size_t* outsize, const char* filename)
{
FILE* file;
- long size;
+ INT64 size;
/*provide some proper output values if error will happen*/
*out = 0;
if(!file) return 78;
/*get filesize:*/
- fseek(file , 0 , SEEK_END);
- size = ftell(file);
+ _fseeki64(file , 0 , SEEK_END);
+ size = _ftelli64(file);
rewind(file);
/*read contents of the file into the vector*/
static BOOL SamLookupStart(WINPR_SAM* sam)
{
size_t readSize;
- long int fileSize;
+ INT64 fileSize;
- fseek(sam->fp, 0, SEEK_END);
- fileSize = ftell(sam->fp);
- fseek(sam->fp, 0, SEEK_SET);
+ _fseeki64(sam->fp, 0, SEEK_END);
+ fileSize = _ftelli64(sam->fp);
+ _fseeki64(sam->fp, 0, SEEK_SET);
if (fileSize < 1)
return FALSE;
{
int success = 0;
void *a = NULL;
- long src_size;
+ INT64 src_size;
FILE *fsrc = fopen(src, "rb");
if (!fsrc)
goto cleanup;
}
- if (fseek(fsrc, 0, SEEK_END))
+ if (_fseeki64(fsrc, 0, SEEK_END))
{
fprintf(stderr, "Failed to seek to file end\n");
goto cleanup;
}
- src_size = ftell(fsrc);
+ src_size = _ftelli64(fsrc);
- if (fseek(fsrc, 0, SEEK_SET))
+ if (_fseeki64(fsrc, 0, SEEK_SET))
{
fprintf(stderr, "Failed to seek to SEEK_SET\n");
goto cleanup;
static BOOL Pcap_HasNext_Record(wPcap* pcap)
{
- if (pcap->file_size - (ftell(pcap->fp)) <= 16)
+ if (pcap->file_size - (_ftelli64(pcap->fp)) <= 16)
return FALSE;
return TRUE;
}
else
{
- if (fseek(pcap->fp, 0, SEEK_END) < 0)
+ if (_fseeki64(pcap->fp, 0, SEEK_END) < 0)
goto out_fail;
- pcap->file_size = (int) ftell(pcap->fp);
+ pcap->file_size = _ftelli64(pcap->fp);
if (pcap->file_size < 0)
goto out_fail;
- if (fseek(pcap->fp, 0, SEEK_SET) < 0)
+ if (_fseeki64(pcap->fp, 0, SEEK_SET) < 0)
goto out_fail;
if (!Pcap_Read_Header(pcap, &pcap->header))
goto out_fail;