mirror of
https://github.com/TomHarte/CLK.git
synced 2025-12-20 06:16:41 +00:00
Avoiding losing channel number; implement EOF check.
This commit is contained in:
@@ -63,13 +63,14 @@ void HostFSHandler::perform(const uint8_t function, uint8_t &a, uint16_t &bc, ui
|
|||||||
function == uint8_t(EXOS::Function::CreateChannel) ?
|
function == uint8_t(EXOS::Function::CreateChannel) ?
|
||||||
Storage::FileMode::Rewrite : Storage::FileMode::ReadWrite;
|
Storage::FileMode::Rewrite : Storage::FileMode::ReadWrite;
|
||||||
|
|
||||||
set_error(EXOS::Error::NoError);
|
|
||||||
try {
|
try {
|
||||||
channels_.emplace(a, bundle_->open(name, mode));
|
channels_.emplace(a, bundle_->open(name, mode));
|
||||||
|
set_error(EXOS::Error::NoError);
|
||||||
} catch(Storage::FileHolder::Error) {
|
} catch(Storage::FileHolder::Error) {
|
||||||
if(mode == Storage::FileMode::ReadWrite) {
|
if(mode == Storage::FileMode::ReadWrite) {
|
||||||
try {
|
try {
|
||||||
channels_.emplace(a, bundle_->open(name, Storage::FileMode::Read));
|
channels_.emplace(a, bundle_->open(name, Storage::FileMode::Read));
|
||||||
|
set_error(EXOS::Error::NoError);
|
||||||
} catch(Storage::FileHolder::Error) {
|
} catch(Storage::FileHolder::Error) {
|
||||||
set_error(EXOS::Error::FileDoesNotExist);
|
set_error(EXOS::Error::FileDoesNotExist);
|
||||||
}
|
}
|
||||||
@@ -77,6 +78,8 @@ void HostFSHandler::perform(const uint8_t function, uint8_t &a, uint16_t &bc, ui
|
|||||||
set_error(EXOS::Error::FileAlreadyExists);
|
set_error(EXOS::Error::FileAlreadyExists);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: FileAlreadyOpen, FileAlreadyExists.
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
// Page 54.
|
// Page 54.
|
||||||
@@ -99,8 +102,13 @@ void HostFSHandler::perform(const uint8_t function, uint8_t &a, uint16_t &bc, ui
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto next = channel->second.get();
|
||||||
|
if(!channel->second.eof()) {
|
||||||
set_error(EXOS::Error::NoError);
|
set_error(EXOS::Error::NoError);
|
||||||
set_c(channel->second.get());
|
set_c(next);
|
||||||
|
} else {
|
||||||
|
set_error(EXOS::Error::EndOfFileMetInRead);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user