NSFileManager check for file or directory

Discussion in 'iPhone/iPad Programming' started by larswik, Feb 8, 2012.

  1. macrumors 68000

    Joined:
    Sep 8, 2006
    #1
    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!
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    I don't think NSFileManager can deal with the web at all.
     
  3. thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #3
    OK, that would explain why it cant see a directory I created on my server and it is returning false.

    Thanks.
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Yeah, I think it only works with file URLs, not all URLs in general
     
  5. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #5
    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.
     
  6. thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #6
    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.
     
  7. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #7
    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.
     

Share This Page