Thread: Macintosh Directory Structures

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    3

    Macintosh Directory Structures

    Hi. I'm trying to write a program which loads a file from within the directory structure of a macintosh. Because they use colons instead of backslash, I thought that this code would work:

    #include <stdio.h>
    FILE *infile;
    infile = fopen("The Cube:Users:davidparker:Desktop:Bills
    Stuff:Majbook-J01:J-200220ubs","r");

    But it doesn't. It reads the entire thing as the name of the file, and assumes it's in the root directory. I.e. it does not read the colon in the string as a directory flag - merely as part of the name.

    I tried something like 12 different possibilities, but nothing seemed to work.

    If anybody knows either how I can solve this, or where I should be looking, I would be v grateful.

    Cheers,
    Bill

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    102
    Please check out the portability of fopen function.
    Saravanan.T.S.
    Beginner.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    3
    It's defined in ANSI-C. I know that the fopen function works with same-directory files, eg

    infile = fopen(test.txt);

    it's just the directory structure I'm having trouble

  4. #4
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    You don't use fopen on a Mac-- you us the FSOpen()-- you gotta use the Mac API. It's not even worth programming a Mac unless you use the API.

    Mac files have 2 forks-- it's a much superior file system. You want to open the Data fork.
    It is not the spoon that bends, it is you who bends around the spoon.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    34

    Smile

    MacOS uses COLONS as dir-seperations ? OH MY GOD ... .

    For an operating system is basicly written out of BSD (UNIX!!),
    it is a strange thing that MacOS uses colons ... .
    But I am not a friend of commercial Operating Systems at all
    :-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  3. Replies: 6
    Last Post: 07-30-2003, 03:08 AM
  4. Directory reading trouble
    By samGwilliam in forum Linux Programming
    Replies: 0
    Last Post: 03-10-2002, 09:43 AM
  5. Methods for Sorting Structures by Element...
    By Sebastiani in forum C Programming
    Replies: 9
    Last Post: 09-14-2001, 12:59 PM