17#if __DCL_HAVE_ALLOC_DEBUG
18#undef __DCL_ALLOC_LEVEL
19#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
39FileInputStream::FileInputStream(
const String& _path)
47FileInputStream::FileInputStream(
const wchar_t* _path)
61 switch (_pFile->fileType())
69 DWORD dwInBufferSize = 0;
70 if (GetNamedPipeInfo(_pFile->handle(),
NULL,
NULL, &dwInBufferSize,
NULL))
79 if (fstat(_pFile->handle(), &st))
81 if (S_ISBLK(st.st_mode))
89FileInputStream::FileInputStream(
File& _file)
94 __closeDestroy =
false;
97FileInputStream::FileInputStream(File::HandleType _handle)
100 File* pFile =
new File(_handle, 0,
false);
111 __closeDestroy =
true;
114void FileInputStream::open(
const String& _path)
120 File* pFile =
new File(_path, File::READONLY);
131 __closeDestroy =
true;
134FileInputStream::~FileInputStream()
142 catch (IOException* e)
152void FileInputStream::close()
173 catch (Exception* cause)
183size_t FileInputStream::available()
191size_t FileInputStream::read(
void* _buf,
size_t _nbytes)
203 return __file->read(_buf, _nbytes);
206 size_t nbytes = _nbytes;
214 size_t nCopy =
__MIN(__cacheSize, nbytes);
215 memcpy(
buf, __cacheStart, nCopy);
216 __cacheStart += nCopy;
217 __cacheSize -= nCopy;
229 size_t nAvail = (
__MIN(nbytes, __file->available()) / __bufSize) * __bufSize;
232 size_t nRead = __file->read(
buf, nAvail);
245 size_t nCacheRead = nbytes % __bufSize;
250 __buf = (
byte_t*)malloc(__bufSize);
255 size_t nRead = __file->read(__buf, __bufSize);
259 __cacheStart = __buf;
262 size_t nCopy =
__MIN(__cacheSize, nbytes);
263 memcpy(
buf, __cacheStart, nCopy);
264 __cacheStart += nCopy;
265 __cacheSize -= nCopy;
274 return _nbytes - nbytes;
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_ASSERT_PARAM(expr)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
#define __DCL_ASSERT_HANDLE(expr)
virtual void close() __DCL_THROWS1(IOException *)
virtual String toString() const
virtual String toString() const
virtual String toString() const
size_t __MIN(size_t x, size_t y)
__DCL_BEGIN_NAMESPACE size_t __ADD_OVERFLOW_MAX(size_t x, size_t y)