The directory magically turns into a file
I am creating a directory in viewDidLoad
the Documents folder of my application.
NSString *localDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
self.projectsLocalPath = [localDirectory stringByAppendingPathComponent:@"Projects"];
if ([[NSFileManager defaultManager] fileExistsAtPath:self.projectsLocalPath] == NO) {
[[NSFileManager defaultManager] createDirectoryAtPath:self.projectsLocalPath withIntermediateDirectories:YES attributes:nil error:nil];
}
After that, I list all the files so that they appear in the logs, checking if it is a directory or not:
//----- LIST ALL FILES -----
NSArray *contentOfFolder = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:localDirectory error:nil];
for (NSString *aPath in contentOfFolder) {
NSString *fullPath = [localDirectory stringByAppendingPathComponent:aPath];
BOOL isDir;
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath isDirectory:&isDir] && isDir) {
NSLog(@"%@ - IT IS A DIR", fullPath);
}
else {
NSLog(@"%@ - IT IS NOT A DIR", fullPath);
}
}
When I first run the application, the list of log files looks like this:
/ var / mobile / Containers / Data / Application / E3 ... 94 / Documents / Project.sqlite - IT'S NOT A BUSINESS
/ var / mobile / Containers / Data / Application / E3 ... 94 / Documents / Project.sqlite-shm - NOT DIR
/ var / mobile / Containers / Data / Application / E3 ... 94 / Docs / Project.sqlite-wal - NOT DIR
/ var / mobile / Containers / Data / Application / E3 ... 94 / Documents / Projects - IT DIR
Everything is correct. But the following logs show that the folder is Projects
no longer a directory.
/ var / mobile / Containers / Data / Application / E3 ... 94 / Documents / Project.sqlite - IT'S NOT A BUSINESS
/ var / mobile / Containers / Data / Application / E3 ... 94 / Documents / Project.sqlite-shm - NOT DIR
/ var / mobile / Containers / Data / Application / E3 ... 94 / Docs / Project.sqlite-wal - NOT DIR
/ var / mobile / Containers / Data / Application / E3 ... 94 / Documents / Projects - IT'S NOT A BUSINESS
It looks like it magically converts to a file ... The problem is that when I want to see the contents of a directory, I get an error saying it is NOT a directory.
Am I doing something wrong? This problem is driving me crazy ...
Thanks everyone for your help in advance.
EDIT:
When you first start, when a directory is created, I load some files and save them to the newly created directory using API-interface Dropbox: [self.restClient loadFile:plan.path intoPath:self.projectsLocalPath];
. There are no errors when saving files to this directory.
source to share
By calling:
[self.restClient loadFile:plan.path intoPath:self.projectsLocalPath];
you are asking the client-client to put a file in a folder - replace the folder - do not put it in a folder.
You need to create the full path to the target file, including the filename inside the folder.
source to share