mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-01-30 10:35:37 +02:00
Improve cdc_fuse_fs and path (#2)
Improve cdc_fuse_fs and path Improves the error handling in path so that std:error_codes are not assumed to be of system category, and also that their messages are displayed. Also improves debug messages in GameletComponent.
This commit is contained in:
@@ -334,8 +334,7 @@ void Indexer::Worker::Run() {
|
||||
absl::Status Indexer::Worker::IndexFile(const std::string& filepath) {
|
||||
std::FILE* fin = std::fopen(filepath.c_str(), "rb");
|
||||
if (!fin) {
|
||||
return ErrnoToCanonicalStatus(
|
||||
errno, absl::StrFormat("failed to open file '%s'", filepath));
|
||||
return ErrnoToCanonicalStatus(errno, "failed to open file '%s'", filepath);
|
||||
}
|
||||
path::FileCloser closer(fin);
|
||||
std::fseek(fin, 0, SEEK_SET);
|
||||
@@ -349,8 +348,8 @@ absl::Status Indexer::Worker::IndexFile(const std::string& filepath) {
|
||||
size_t cnt = std::fread(buf.data(), sizeof(uint8_t), buf.size(), fin);
|
||||
err = std::ferror(fin);
|
||||
if (err) {
|
||||
return ErrnoToCanonicalStatus(
|
||||
err, absl::StrFormat("failed to read from file '%s'", filepath));
|
||||
return ErrnoToCanonicalStatus(err, "failed to read from file '%s'",
|
||||
filepath);
|
||||
}
|
||||
if (cnt) {
|
||||
chunker.Process(buf.data(), cnt);
|
||||
|
||||
@@ -273,8 +273,8 @@ absl::Status WriteResultsFile(const std::string& filepath,
|
||||
bool exists = path::FileExists(filepath);
|
||||
std::FILE* fout = std::fopen(filepath.c_str(), "a");
|
||||
if (!fout) {
|
||||
return ErrnoToCanonicalStatus(
|
||||
errno, absl::StrFormat("Couldn't write to file '%s'", filepath));
|
||||
return ErrnoToCanonicalStatus(errno, "Couldn't write to file '%s'",
|
||||
filepath);
|
||||
}
|
||||
|
||||
path::FileCloser closer(fout);
|
||||
|
||||
Reference in New Issue
Block a user