2008-07-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Introduced a2_struct_stat. It is defined as `struct _stati64' if
	__MINGW32__ is defined, because under MinGW32, _stati64 is used 
and its
	second argument is of type `struct _stati64'. Otherwise it is 
defined as
	`struct stat'.
	* src/AbstractDiskWriter.cc
	* src/File.cc
	* src/File.h
	* src/a2io.h
pull/1/head
Tatsuhiro Tsujikawa 2008-07-06 04:38:54 +00:00
parent 46f081f1db
commit cfa808126b
5 changed files with 21 additions and 8 deletions

View File

@ -1,3 +1,14 @@
2008-07-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Introduced a2_struct_stat. It is defined as `struct _stati64' if
__MINGW32__ is defined, because under MinGW32, _stati64 is used and its
second argument is of type `struct _stati64'. Otherwise it is defined as
`struct stat'.
* src/AbstractDiskWriter.cc
* src/File.cc
* src/File.h
* src/a2io.h
2008-07-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com> 2008-07-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the compile error in hurd-i386 Fixed the compile error in hurd-i386

View File

@ -168,7 +168,7 @@ uint64_t AbstractDiskWriter::size() const
if(fd == -1) { if(fd == -1) {
throw DlAbortEx("File not opened."); throw DlAbortEx("File not opened.");
} }
struct stat fileStat; a2_struct_stat fileStat;
if(fstat(fd, &fileStat) < 0) { if(fstat(fd, &fileStat) < 0) {
return 0; return 0;
} }

View File

@ -50,17 +50,17 @@ File::File(const std::string& name):name(name) {}
File::~File() {} File::~File() {}
int File::fillStat(struct stat& fstat) { int File::fillStat(a2_struct_stat& fstat) {
return stat(name.c_str(), &fstat); return stat(name.c_str(), &fstat);
} }
bool File::exists() { bool File::exists() {
struct stat fstat; a2_struct_stat fstat;
return fillStat(fstat) == 0; return fillStat(fstat) == 0;
} }
bool File::isFile() { bool File::isFile() {
struct stat fstat; a2_struct_stat fstat;
if(fillStat(fstat) < 0) { if(fillStat(fstat) < 0) {
return false; return false;
} }
@ -68,7 +68,7 @@ bool File::isFile() {
} }
bool File::isDir() { bool File::isDir() {
struct stat fstat; a2_struct_stat fstat;
if(fillStat(fstat) < 0) { if(fillStat(fstat) < 0) {
return false; return false;
} }
@ -86,7 +86,7 @@ bool File::remove() {
} }
uint64_t File::size() { uint64_t File::size() {
struct stat fstat; a2_struct_stat fstat;
if(fillStat(fstat) < 0) { if(fillStat(fstat) < 0) {
return 0; return 0;
} }
@ -122,7 +122,7 @@ bool File::mkdirs() {
mode_t File::mode() mode_t File::mode()
{ {
struct stat fstat; a2_struct_stat fstat;
if(fillStat(fstat) < 0) { if(fillStat(fstat) < 0) {
return 0; return 0;
} }

View File

@ -51,7 +51,7 @@ private:
/** /**
* Returns the return value of stat(...) * Returns the return value of stat(...)
*/ */
int fillStat(struct stat& fstat); int fillStat(a2_struct_stat& fstat);
public: public:
File(const std::string& name); File(const std::string& name);
~File(); ~File();

View File

@ -119,10 +119,12 @@
# ifdef stat # ifdef stat
# undef stat # undef stat
# endif // stat # endif // stat
# define a2_struct_stat struct _stati64
# define stat(path, buf) _stati64(path, buf) # define stat(path, buf) _stati64(path, buf)
# define tell(handle) _telli64(handle) # define tell(handle) _telli64(handle)
# define a2mkdir(path, openMode) mkdir(path) # define a2mkdir(path, openMode) mkdir(path)
#else #else
# define a2_struct_stat struct stat
# define a2mkdir(path, openMode) mkdir(path, openMode) # define a2mkdir(path, openMode) mkdir(path, openMode)
#endif // __MINGW32__ #endif // __MINGW32__