This is a migrated thread and some comments may be shown as answers.

can't create persistent directory or subdirectories, get PATH_EXISTS_ERR

1 Answer 657 Views
Apache Cordova
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Roger
Top achievements
Rank 1
Roger asked on 26 Oct 2013, 10:36 PM
Hi,
have got a file system handle and can create a file on the root directory but am trying to create a subdirectory for my app where the files are stored. I use the command:

fileSystem.root.getDirectory("/lightning/attachments/",{create: true, exclusive: false}, function(dir){alert("Created dir "+dir.name);},function(error){alert("Error creating directory "+fileErrorCode(error.code));})

where fileErrorCode converts the code into a text sting as per the phonegap FileError code API.

I get back  an error code of 12 which translates to "PATH_EXISTS_ERR"
Have tried adding the file system root to the path with the same result.
Lookin on the web I found a similar thing on google groups:
https://groups.google.com/forum/#!msg/phonegap/CUJO1qLZK0g/PgByaUEykoQJ
who recommends adding to config.xml:
<feature name="http://api.phonegap.com/1.0/file"/>   with the appropriate phonegap version of course.
but where do I add it (if this is the solution).
I can see from the Icenium xml for Android that the file plugin is included.
I am testing on a Galaxy S3 & all the examples show writing and reading in the root directory (which works)
Probably my next post will be how to write and read to the subdirectory !!!
Any suggestions??


1 Answer, 1 is accepted

Sort by
0
Accepted
Roger
Top achievements
Rank 1
answered on 27 Oct 2013, 12:57 AM
Found the problem...need to do it simply and 1 at a time...so

fileSystem.root.getDirectory("lightning",{create: true, exclusive: false}, function(dir){alert("Created dir "+dir.name);},function(error){alert("Error creating directory "+ fileErrorCode(error.code));})

creates the directory "lightning"
and
MyApp.fileSystem.root.getDirectory("lightning/attachments",{create: true, exclusive: false}, function(dir){alert("Created dir "+dir.name);},function(error){alert("Error creating directory "+fileErrorCode(error.code));})

will create the subdirectory "attachments" on "lightning"...checked the phone folders and there it is !!!! Lightning/attachments
Tags
Apache Cordova
Asked by
Roger
Top achievements
Rank 1
Answers by
Roger
Top achievements
Rank 1
Share this question
or