18#if __DCL_HAVE_ALLOC_DEBUG
19#undef __DCL_ALLOC_LEVEL
20#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
23#if __DCL_HAVE_THIS_FILE__
42FileInputStream::FileInputStream(
const String& _path)
50FileInputStream::FileInputStream(
const wchar_t* _path)
64 switch (_file->fileType()) {
70 DWORD dwInBufferSize = 0;
71 if (GetNamedPipeInfo(_file->handle(),
NULL,
NULL, &dwInBufferSize,
NULL))
82 if (!isatty(_file->handle())) {
84 if (fstat(_file->handle(), &st)) {
94FileInputStream::FileInputStream(
File& _file)
99 __closeDestroy =
false;
102FileInputStream::FileInputStream(File::HandleType _handle)
105 File* file =
new File(_handle, 0,
false);
114 __closeDestroy =
true;
117void FileInputStream::open(
const String& _path)
124 File* file =
new File(_path, File::READONLY);
133 __closeDestroy =
true;
136FileInputStream::~FileInputStream()
142 catch (IOException* _e) {
151void FileInputStream::close()
169 catch (Exception* _cause) {
179size_t FileInputStream::available() const
187size_t FileInputStream::read(
void* _buf,
size_t _nbytes)
198 return __file->read(_buf, _nbytes);
201 size_t nbytes = _nbytes;
208 size_t nCopy =
__MIN(__cacheSize, nbytes);
209 memcpy(buf, __cacheStart, nCopy);
210 __cacheStart += nCopy;
211 __cacheSize -= nCopy;
222 size_t nAvail = (
__MIN(nbytes, __file->available()) / __bufSize) * __bufSize;
224 size_t nRead = __file->read(buf, nAvail);
235 size_t nCacheRead = nbytes % __bufSize;
238 __buf = (
byte_t*)malloc(__bufSize);
243 size_t nRead = __file->read(__buf, __bufSize);
246 __cacheStart = __buf;
249 size_t nCopy =
__MIN(__cacheSize, nbytes);
250 memcpy(buf, __cacheStart, nCopy);
251 __cacheStart += nCopy;
252 __cacheSize -= nCopy;
261 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)