00001
00002
00003 #ifndef BASE_SIZETRAITS_H
00004 #define BASE_SIZETRAITS_H
00005
00006 #ifdef _WIN32
00007 #define WIN32_LEAN_AND_MEAN
00008 #include <windows.h>
00009 #else
00010 #include <ctime>
00011 #include <sys/stat.h>
00012 #endif
00013 #include "portable.h"
00014
00015 namespace base {
00017 template<class sizeT> struct PPBASE_EXPORT SizeTraits {};
00018
00020 template<> struct PPBASE_EXPORT SizeTraits<size_t> {
00021 typedef size_t size_type;
00022 typedef int ssize_type;
00023 #ifdef _WIN32
00024 static ssize_type lseek(HANDLE fd, ssize_type pos, DWORD whence);
00025 static size_type size(const WIN32_FIND_DATAA &st);
00026 static size_type size(const WIN32_FIND_DATAW &st);
00027 static size_type size(const BY_HANDLE_FILE_INFORMATION &st);
00028 #else
00029 typedef struct stat stat_type;
00030
00032 static int fstat(int fd, stat_type *st);
00034 static ssize_type lseek(int fd, ssize_type ofs, int whence);
00036 static int stat(const char *fn, stat_type *st);
00038 static int truncate(int fd, size_type len);
00039 #endif
00040 };
00041
00042 #ifndef _WIN64
00043
00044 template<> struct PPBASE_EXPORT SizeTraits<u_longlong_t> {
00045 typedef u_longlong_t size_type;
00046 typedef longlong_t ssize_type;
00047 #ifdef _WIN32
00048 static ssize_type lseek(HANDLE fd, ssize_type pos, DWORD whence);
00049 static size_type size(const WIN32_FIND_DATAA &st);
00050 static size_type size(const WIN32_FIND_DATAW &st);
00051 static size_type size(const BY_HANDLE_FILE_INFORMATION &st);
00052 #else
00053 typedef struct stat64 stat_type;
00054
00056 static int fstat(int fd, stat_type *st);
00058 static ssize_type lseek(int fd, ssize_type ofs, int whence);
00060 static int stat(const char *fn, stat_type *st);
00062 static int truncate(int fd, size_type len);
00063 #endif
00064 };
00065 #endif
00066 }
00067
00068 #endif