17#if __DCL_HAVE_ALLOC_DEBUG
18#undef __DCL_ALLOC_LEVEL
19#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
22#if __DCL_HAVE_THIS_FILE__
41FileOutputStream::FileOutputStream(
const String& _path,
bool _truncate)
45 open(_path, _truncate);
54 switch (_file->fileType()) {
60 DWORD dwOutBufferSize = 0;
61 if (GetNamedPipeInfo(_file->handle(),
NULL, &dwOutBufferSize,
NULL,
NULL)) {
71 if (!isatty(_file->handle())) {
73 if (fstat(_file->handle(), &st)) {
82FileOutputStream::FileOutputStream(
File& _file)
87 __closeDestroy =
false;
90FileOutputStream::FileOutputStream(File::HandleType _handle)
93 File* file =
new File(_handle, 0,
false);
102 __closeDestroy =
true;
117 __closeDestroy =
true;
120void FileOutputStream::open(
const String& _path,
bool _truncate)
126 File* file =
new File(_path, File::WRITEONLY | File::CREATE
127 | (_truncate ? File::TRUNCATE : File::APPEND));
136 __closeDestroy =
true;
139FileOutputStream::~FileOutputStream()
145 catch (IOException* _e) {
153void FileOutputStream::close()
161 catch (Exception* _cause) {
178 catch (Exception* _cause) {
195 size_t n = _file->
write(_buf + written, _nbytes);
209void FileOutputStream::flush()
219OutputStream& FileOutputStream::write(
const void* _buf,
size_t _nbytes)
234 size_t n = (size_t)_nbytes;
236 size_t nCopySize = __bufSize - __dataSize;
237 if ((__dataSize > 0) || (nCopySize > n)) {
241 __buf = (
byte_t*)malloc(__bufSize);
247 memcpy(__buf + __dataSize, buf, nCopySize);
248 __dataSize += nCopySize;
252 if (__dataSize == __bufSize) {
264 size_t nBlockWrite = (n / __bufSize) * __bufSize;
265 nCopySize = n % __bufSize;
267 size_t written =
__write(__file, buf, nBlockWrite);
276 __buf = (
byte_t*)malloc(__bufSize);
280 memcpy(__buf, buf, nCopySize);
281 __dataSize += nCopySize;
size_t __write(File *_file, const byte_t *_buf, size_t _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 size_t write(const void *_buf, size_t _n) __DCL_THROWS1(IOException *)
void init(File *_file) __DCL_THROWS1(IOException *)
virtual String toString() const
virtual String toString() const
static void sleep(unsigned int _mills)