summaryrefslogtreecommitdiff
path: root/Source/Library/Common
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Library/Common')
-rw-r--r--Source/Library/Common/FileStream.class.cpp11
-rw-r--r--Source/Library/Common/IStream.proto.cpp5
-rw-r--r--Source/Library/Common/OStream.proto.cpp4
3 files changed, 14 insertions, 6 deletions
diff --git a/Source/Library/Common/FileStream.class.cpp b/Source/Library/Common/FileStream.class.cpp
index 322e9aa..317a023 100644
--- a/Source/Library/Common/FileStream.class.cpp
+++ b/Source/Library/Common/FileStream.class.cpp
@@ -6,11 +6,13 @@
FileIStream::FileIStream(const String &filename, u8int encoding, FSNode start) : m_start(start) {
m_file = new File(filename, FM_READ, start);
+ m_filenames = 0;
m_encoding = encoding;
}
FileIStream::FileIStream(u8int encoding, FSNode start) : m_start(start) {
m_file = 0;
+ m_filenames = 0;
m_encoding = encoding;
}
@@ -30,10 +32,11 @@ void FileIStream::appendFile(const String &filename) {
}
String FileIStream::read() {
- if (m_file == 0) return "";
- while (m_file->eof() or !m_file->valid()) {
- m_file->close();
- delete m_file;
+ while (m_file == 0 or m_file->eof() or !m_file->valid()) {
+ if (m_file != 0) {
+ m_file->close();
+ delete m_file;
+ }
m_file = 0;
if (m_filenames == 0) {
return "";
diff --git a/Source/Library/Common/IStream.proto.cpp b/Source/Library/Common/IStream.proto.cpp
index 59c623e..6176eac 100644
--- a/Source/Library/Common/IStream.proto.cpp
+++ b/Source/Library/Common/IStream.proto.cpp
@@ -51,7 +51,10 @@ WChar IStream::getChar() {
String IStream::get(WChar delimiter) {
waitLock();
//calculate length of string to read
- if (m_buffer == 0) populate();
+ if (m_buffer == 0) {
+ unlock();
+ if (!populate()) return "";
+ }
int length = 0, ptr = m_ptr;
for (SimpleList<String> *iter = m_buffer; iter != 0;) {
if (iter->v()[ptr] == delimiter) break;
diff --git a/Source/Library/Common/OStream.proto.cpp b/Source/Library/Common/OStream.proto.cpp
index ba876b3..f0667e7 100644
--- a/Source/Library/Common/OStream.proto.cpp
+++ b/Source/Library/Common/OStream.proto.cpp
@@ -11,6 +11,7 @@ OStream::OStream(const OStream& other) {
}
void OStream::put(const String &s) {
+ if (s.empty()) return;
waitLock();
if (m_buffer == NULL or m_last == NULL) {
m_buffer = m_last = new SimpleList<String>(s);
@@ -55,8 +56,9 @@ OStream& OStream::operator<< (ostream_modifiers_e m) {
flush();
} else if (m == ENDL) {
put("\n");
+ flush();
} else if (m == END) {
- put(String(EOF, 1));
+ put(EOF);
flush();
}
return *this;