Professional Web Applications Themes

*Very* strange file behavior... - Mac Programming

I'm trying to create a file in /Library/Preferences. This code was working fine until today, when it just doesn't work at all. It seems that the file manager calls seem to think there's a file even though the file system is reporting otherwise: Boolean isDirectory; FSSpec prefSpec, parentSpec; UInt8 thePath[1024]; memset(thePath, 0, sizeof(thePath)); strcpy((char*)thePath, "/Library/Preferences"); myErr = FSPathMakeFSSpec( thePath, &parentSpec, &isDirectory); myErr = FSMakeFSSpec(parentSpec.vRefNum, parentSpec.parID, "\pmypref", &prefSpec); //even though the file does NOT exist, FSMakeFSSpec does not give a fnfErr! Strange... if ( myErr == fnfErr ) //file doesn't exist { myErr = FSpCreate(&prefSpec,kCreator,kType,smSystemScript) ; } //if I comment out ...

  1. #1

    Default *Very* strange file behavior...

    I'm trying to create a file in /Library/Preferences. This code was working
    fine until today, when it just doesn't work at all. It seems that the file
    manager calls seem to think there's a file even though the file system is
    reporting otherwise:

    Boolean isDirectory;
    FSSpec prefSpec, parentSpec;
    UInt8 thePath[1024];

    memset(thePath, 0, sizeof(thePath));
    strcpy((char*)thePath, "/Library/Preferences");

    myErr = FSPathMakeFSSpec(
    thePath,
    &parentSpec,
    &isDirectory);

    myErr = FSMakeFSSpec(parentSpec.vRefNum, parentSpec.parID, "\pmypref",
    &prefSpec);

    //even though the file does NOT exist, FSMakeFSSpec does not give a fnfErr!
    Strange...

    if ( myErr == fnfErr ) //file doesn't exist
    {
    myErr = FSpCreate(&prefSpec,kCreator,kType,smSystemScript) ;
    }

    //if I comment out the error check above, FSpCreate tells me that there's a
    duplicate file name.

    Any ideas? Thanks in advance!

    -Mike Hunson

    Mike Guest

  2. #2

    Default Re: *Very* strange file behavior...

    On Wed, 1 Oct 2003, Mike H. wrote:
     

    if you want to a FSSpec to a file/folder inside /Library/Preferences, then
    you should
    be passing the directory id of the parent folder as your second
    parameter, not the parID (this will create a fsspec for the item
    /Library/mypref)

    Fred

    PS. hardcoded paths are evil.

    Frederick Guest

  3. #3

    Default Re: *Very* strange file behavior...

    In article <BBA0A492.28BA2%org>,
    "Mike H." <org> wrote:
     

    Save yourself the trouble and use the CFPreferences API. If not, at
    least use FindFolder().
    Sean Guest

Similar Threads

  1. strange behavior in File::Basename
    By perl coder in forum PERL Modules
    Replies: 2
    Last Post: July 24th, 07:51 AM
  2. Strange behavior when saving a file
    By Psychopomp@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 2
    Last Post: June 7th, 10:31 PM
  3. Very strange file upload behavior
    By Courtney L. in forum PHP Development
    Replies: 3
    Last Post: October 2nd, 11:15 PM
  4. Strange behavior of $.
    By Robert Klemme in forum Ruby
    Replies: 1
    Last Post: September 17th, 10:42 AM
  5. Strange behavior after reading big file
    By J Krugman in forum PERL Miscellaneous
    Replies: 4
    Last Post: September 6th, 11:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139