PDA

View Full Version : NSFileManager check for file or directory




larswik
Feb 8, 2012, 07:45 AM
Quick question. I am checking to see if a directory exists on my server. Would I use NSFileManager or something with NSURL? I have been reading the docs but I am not sure if NSFileManager can be used to check if files or directories exist at a give website?

Was not sure if NSFileManager was used for internal computer / iphone file searching or if it is irreverent where it searches for files, web or internal directories?

Thanks!



robbieduncan
Feb 8, 2012, 07:46 AM
I don't think NSFileManager can deal with the web at all.

larswik
Feb 8, 2012, 08:22 AM
OK, that would explain why it cant see a directory I created on my server and it is returning false.

Thanks.

robbieduncan
Feb 8, 2012, 08:24 AM
OK, that would explain why it cant see a directory I created on my server and it is returning false.

Thanks.

Yeah, I think it only works with file URLs, not all URLs in general

PhoneyDeveloper
Feb 8, 2012, 05:55 PM
There are no files or directories on the internet. All that exists are services. In order to find things out about a server you have to ask a service that runs on that server.

A web server can respond with documents if you ask it. There's not a direct way to ask a web server about folders, that I can think of.

larswik
Feb 8, 2012, 06:10 PM
ahhh, it is more complex then I thought. I used Transmit ftp program to create a folder on my site. Before I start to load images and text files I wanted to verify that the folder existed first before it tried.

I used the NSFileManager to locate files and folder on my Mac and iPhone but not the web yet. It got confusing for me today reading the docs because it seems you can use fileAtPath and fileAtRUL to accomplish the same tasks, on the computer or iPhone. I thought fileAtPath, which I use, was for searching for files and directories within my computer / iPhone and anything URL was the internet.

PhoneyDeveloper
Feb 9, 2012, 01:10 PM
ftp is one of those services that can live on the internet.

For various reasons Apple has added a bunch of APIs that take URLs. Some of these use http:// URLs and will download/upload from the internet. Others are strictly file URLs only. It can be difficult to tell which is which.