mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Add support for renaming files.
This commit is contained in:
@@ -51,9 +51,7 @@ private:
|
||||
RolandDirent(const std::string& filename)
|
||||
{
|
||||
file_type = TYPE_FILE;
|
||||
|
||||
this->filename = filename;
|
||||
path = {filename};
|
||||
rename(filename);
|
||||
|
||||
length = 0;
|
||||
attributes[Filesystem::FILENAME] = filename;
|
||||
@@ -62,6 +60,12 @@ private:
|
||||
attributes[Filesystem::MODE] = "";
|
||||
}
|
||||
|
||||
void rename(const std::string& name)
|
||||
{
|
||||
filename = name;
|
||||
path = {filename};
|
||||
}
|
||||
|
||||
void addBlock(RolandFsFilesystem* fs, uint8_t block)
|
||||
{
|
||||
blocks.push_back(block);
|
||||
@@ -97,7 +101,7 @@ public:
|
||||
uint32_t capabilities() const override
|
||||
{
|
||||
return OP_CREATE | OP_GETFSDATA | OP_LIST | OP_GETFILE | OP_PUTFILE |
|
||||
OP_GETDIRENT | OP_DELETE;
|
||||
OP_GETDIRENT | OP_DELETE | OP_MOVE;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> getMetadata() override
|
||||
@@ -215,6 +219,19 @@ public:
|
||||
rewriteDirectory();
|
||||
}
|
||||
|
||||
void moveFile(const Path& oldName, const Path& newName) override
|
||||
{
|
||||
mount();
|
||||
if ((oldName.size() != 1) || (newName.size() != 1))
|
||||
throw BadPathException();
|
||||
if (findFileOrReturnNull(newName.front()))
|
||||
throw BadPathException("File exists");
|
||||
|
||||
auto de = findFile(oldName.front());
|
||||
de->rename(mangleFilename(newName.front()));
|
||||
rewriteDirectory();
|
||||
}
|
||||
|
||||
private:
|
||||
void init()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user