Finishing unique_ptr'ing and fixing file memory management (for now).

This commit is contained in:
Ben Vanik
2014-08-21 07:54:19 -07:00
parent c59d053404
commit 08b0226a16
26 changed files with 152 additions and 175 deletions

View File

@@ -23,7 +23,7 @@ DiscImageFile::DiscImageFile(KernelState* kernel_state, Mode mode,
DiscImageEntry* entry)
: XFile(kernel_state, mode), entry_(entry) {}
DiscImageFile::~DiscImageFile() {}
DiscImageFile::~DiscImageFile() { delete entry_; }
const std::string& DiscImageFile::path() const { return entry_->path(); }

View File

@@ -22,7 +22,10 @@ HostPathFile::HostPathFile(KernelState* kernel_state, Mode mode,
file_handle_(file_handle),
XFile(kernel_state, mode) {}
HostPathFile::~HostPathFile() { CloseHandle(file_handle_); }
HostPathFile::~HostPathFile() {
CloseHandle(file_handle_);
delete entry_;
}
const std::string& HostPathFile::path() const { return entry_->path(); }

View File

@@ -23,7 +23,7 @@ STFSContainerFile::STFSContainerFile(KernelState* kernel_state, Mode mode,
STFSContainerEntry* entry)
: entry_(entry), XFile(kernel_state, mode) {}
STFSContainerFile::~STFSContainerFile() {}
STFSContainerFile::~STFSContainerFile() { delete entry_; }
const std::string& STFSContainerFile::path() const { return entry_->path(); }

View File

@@ -176,6 +176,16 @@ std::unique_ptr<Entry> FileSystem::ResolvePath(const std::string& path) {
return nullptr;
}
X_STATUS FileSystem::Open(std::unique_ptr<Entry> entry,
KernelState* kernel_state, Mode mode, bool async,
XFile** out_file) {
auto result = entry->Open(kernel_state, mode, async, out_file);
if (XSUCCEEDED(result)) {
entry.release();
}
return result;
}
} // namespace fs
} // namespace kernel
} // namespace xe

View File

@@ -52,6 +52,8 @@ class FileSystem {
int DeleteSymbolicLink(const std::string& path);
std::unique_ptr<Entry> ResolvePath(const std::string& path);
X_STATUS Open(std::unique_ptr<Entry> entry, KernelState* kernel_state,
Mode mode, bool async, XFile** out_file);
private:
std::vector<Device*> devices_;