summaryrefslogtreecommitdiff
path: root/Source/Library/Common
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-12-20 19:39:46 +0100
committerAlexis211 <alexis211@gmail.com>2009-12-20 19:39:46 +0100
commit1d301e54da75b90172d129594265f2b629f3125a (patch)
tree1eb918a01ef7677c4328ef1d23a2538647448f0b /Source/Library/Common
parent13d720389a01161a327a30918ad7ac9eec4a3d6c (diff)
downloadMelon-1d301e54da75b90172d129594265f2b629f3125a.tar.gz
Melon-1d301e54da75b90172d129594265f2b629f3125a.zip
rot13, demo app for StreamApp, is working :)
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;