Sample: cleaning up Inheritance
[io/quag.git] / libs / basekit / source / PortableTruncate.c
blobc6c05fa118fb64d725c10f2dd2f2339b45b4571a
2 #include "PortableTruncate.h"
5 int PortableTruncate_justHereToAvoidRanlibWarning(void) { return 0; }
7 #ifdef _WIN32
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
12 #include <windows.h>
14 // Win32 truncate by Mike Austin
16 int truncate(const char *path, long length)
18 HANDLE file = CreateFile(path, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
19 FILE_SHARE_WRITE | FILE_SHARE_READ, NULL);
21 if (file == INVALID_HANDLE_VALUE)
23 return -1;
26 if (SetFilePointer(file, length, NULL, FILE_BEGIN) == 0xFFFFFFFF || !SetEndOfFile(file))
28 CloseHandle(file);
29 return -1;
32 CloseHandle(file);
33 return 0;
36 #endif
38 #if defined(__SYMBIAN32__)
39 int truncate(const char* path, long length)
41 // TODO: Implement for Symbian
42 return -1;
44 #endif