X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Ffilesystem%2Fbyte_filer.cpp;h=e091996b2aed96f01bcd3be1574020f940f6727a;hb=e77d89eb4a86eb0baa2daddc3c5a9567111e5bc2;hp=005b2955c92dee5c86dacca37a8492092a6a2081;hpb=b51411a29f1a751a09e69f5676afeea24a94ac83;p=feisty_meow.git diff --git a/nucleus/library/filesystem/byte_filer.cpp b/nucleus/library/filesystem/byte_filer.cpp index 005b2955..e091996b 100644 --- a/nucleus/library/filesystem/byte_filer.cpp +++ b/nucleus/library/filesystem/byte_filer.cpp @@ -29,7 +29,7 @@ #include #endif -//#define DEBUG_BYTE_FILER +#define DEBUG_BYTE_FILER // uncomment for noisy version of class. using namespace basis; @@ -44,7 +44,7 @@ class file_hider public: FILE *fp; // the real file pointer. - file_hider() : fp(NIL) {} + file_hider() : fp(NULL_POINTER) {} }; ////////////// @@ -79,7 +79,7 @@ byte_filer::byte_filer(bool auto_close, void *handle) byte_filer::~byte_filer() { close(); WHACK(_handle); WHACK(_filename); } -astring byte_filer::name() const { return _filename->raw(); } +const astring &byte_filer::name() const { return _filename->raw(); } size_t byte_filer::file_size_limit() { return BTFL_FILE_TELL_LIMIT; } @@ -88,19 +88,8 @@ bool byte_filer::open(const astring &fname, const astring &perms) close(); _auto_close = true; // reset since we know we're opening this. _filename->reset(fname); -#ifndef __WIN32__ - _handle->fp = _filename->raw().t()? fopen(_filename->raw().s(), perms.s()) : NIL; -#else - _handle->fp = _filename->raw().t()? _wfopen((wchar_t *)(UTF16 *)transcode_to_utf16(_filename->raw()), - (wchar_t *)(UTF16 *)transcode_to_utf16(perms)) : NIL; - -#ifdef DEBUG_BYTE_FILER - if (!_handle->fp) - wprintf((wchar_t *)(UTF16 *)transcode_to_utf16("could not open: %ls\n"), - (wchar_t *)(UTF16 *)transcode_to_utf16(_filename->raw())); -#endif - -#endif + _handle->fp = _filename->raw().t()? fopen(_filename->raw().s(), perms.s()) : NULL_POINTER; + if (_handle->fp == NULL_POINTER) return false; return good(); } @@ -108,7 +97,7 @@ void byte_filer::close() { _filename->reset(""); if (_auto_close && _handle->fp) fclose(_handle->fp); - _handle->fp = NIL; + _handle->fp = NULL_POINTER; } bool byte_filer::good() { return !!_handle->fp; }