mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 11:51:52 +00:00
ANDROID: Allow to create a /saf node from path
This avoids errors when creating parent directories in DumpFile This also allows the user to specify /saf path in browser to allow browsing.
This commit is contained in:
parent
98a0aab3f4
commit
9d879cb04f
@ -53,10 +53,14 @@ AbstractFSNode *AndroidFilesystemFactory::makeFileNodePath(const Common::String
|
||||
return makeRootFileNode();
|
||||
}
|
||||
|
||||
// No need to take SAF add mode here as it's called only for paths and we won't accept /saf path to make a new SAF
|
||||
|
||||
// If SAF works, it was a SAF URL
|
||||
if (_withSAF) {
|
||||
// Accept /saf as it can be used to create the tree in DumpFile
|
||||
if (path == AddSAFFakeNode::SAF_ADD_FAKE_PATH) {
|
||||
// Not a SAF mount point
|
||||
return new AddSAFFakeNode(true);
|
||||
}
|
||||
|
||||
AbstractFSNode *node = AndroidSAFFilesystemNode::makeFromPath(path);
|
||||
if (node) {
|
||||
return node;
|
||||
@ -90,7 +94,7 @@ void AndroidFilesystemFactory::getSAFTrees(AbstractFSList &list, bool allowSAFad
|
||||
}
|
||||
|
||||
if (allowSAFadd) {
|
||||
list.push_back(new AddSAFFakeNode());
|
||||
list.push_back(new AddSAFFakeNode(false));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,13 +30,7 @@ AbstractFSNode *AndroidPOSIXFilesystemNode::makeNode() const {
|
||||
}
|
||||
|
||||
AbstractFSNode *AndroidPOSIXFilesystemNode::makeNode(const Common::String &path) const {
|
||||
// If SAF works, it was a SAF URL
|
||||
AbstractFSNode *node = AndroidSAFFilesystemNode::makeFromPath(path);
|
||||
if (node) {
|
||||
return node;
|
||||
}
|
||||
|
||||
return new AndroidPOSIXFilesystemNode(path, _config);
|
||||
return AndroidFilesystemFactory::instance().makeFileNodePath(path);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -586,6 +586,10 @@ AddSAFFakeNode::~AddSAFFakeNode() {
|
||||
}
|
||||
|
||||
AbstractFSNode *AddSAFFakeNode::getChild(const Common::String &name) const {
|
||||
if (_fromPath) {
|
||||
// When starting from /saf try to get the tree node
|
||||
return AndroidSAFFilesystemNode::makeFromPath(Common::String(AndroidSAFFilesystemNode::SAF_MOUNT_POINT) + name);
|
||||
}
|
||||
// We can't call getChild as it's protected
|
||||
return nullptr;
|
||||
}
|
||||
@ -596,6 +600,11 @@ AbstractFSNode *AddSAFFakeNode::getParent() const {
|
||||
}
|
||||
|
||||
bool AddSAFFakeNode::exists() const {
|
||||
if (_fromPath) {
|
||||
// /saf always exists when created as a path
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_proxied) {
|
||||
makeProxySAF();
|
||||
}
|
||||
@ -608,6 +617,16 @@ bool AddSAFFakeNode::exists() const {
|
||||
}
|
||||
|
||||
bool AddSAFFakeNode::getChildren(AbstractFSList &list, ListMode mode, bool hidden) const {
|
||||
if (_fromPath) {
|
||||
// When built from path, /saf lists all SAF node but never proposes to add one
|
||||
if (mode == Common::FSNode::kListFilesOnly) {
|
||||
// All directories
|
||||
return true;
|
||||
}
|
||||
AndroidFilesystemFactory::instance().getSAFTrees(list, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_proxied) {
|
||||
makeProxySAF();
|
||||
}
|
||||
@ -620,6 +639,10 @@ bool AddSAFFakeNode::getChildren(AbstractFSList &list, ListMode mode, bool hidde
|
||||
}
|
||||
|
||||
Common::String AddSAFFakeNode::getPath() const {
|
||||
if (_fromPath) {
|
||||
return SAF_ADD_FAKE_PATH;
|
||||
}
|
||||
|
||||
if (!_proxied) {
|
||||
makeProxySAF();
|
||||
}
|
||||
@ -632,6 +655,10 @@ Common::String AddSAFFakeNode::getPath() const {
|
||||
}
|
||||
|
||||
bool AddSAFFakeNode::isReadable() const {
|
||||
if (_fromPath) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_proxied) {
|
||||
makeProxySAF();
|
||||
}
|
||||
@ -644,6 +671,10 @@ bool AddSAFFakeNode::isReadable() const {
|
||||
}
|
||||
|
||||
bool AddSAFFakeNode::isWritable() const {
|
||||
if (_fromPath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_proxied) {
|
||||
makeProxySAF();
|
||||
}
|
||||
@ -656,6 +687,8 @@ bool AddSAFFakeNode::isWritable() const {
|
||||
}
|
||||
|
||||
void AddSAFFakeNode::makeProxySAF() const {
|
||||
assert(!_fromPath);
|
||||
|
||||
if (_proxied) {
|
||||
return;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ protected:
|
||||
public:
|
||||
static const char SAF_ADD_FAKE_PATH[];
|
||||
|
||||
AddSAFFakeNode() : _proxied(nullptr) { }
|
||||
AddSAFFakeNode(bool fromPath) : _proxied(nullptr), _fromPath(fromPath) { }
|
||||
~AddSAFFakeNode() override;
|
||||
|
||||
bool exists() const override;
|
||||
@ -187,6 +187,7 @@ public:
|
||||
private:
|
||||
void makeProxySAF() const;
|
||||
|
||||
bool _fromPath;
|
||||
mutable AbstractFSNode *_proxied;
|
||||
};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user