Professional Web Applications Themes

What causes error code -37? - Mac Programming

I'm using FSPCreate to create a text file, and no matter what I type for the filename I'm getting an error -37 (bad file name) error being thrown. Does anyone have any ideas what causes this type of error to be thrown? In what way is the name "bad" when this error is thrown? CT...

  1. #1

    Default What causes error code -37?

    I'm using FSPCreate to create a text file, and no matter what I type for
    the filename I'm getting an error -37 (bad file name) error being thrown.

    Does anyone have any ideas what causes this type of error to be thrown?

    In what way is the name "bad" when this error is thrown?

    CT
    Charles Guest

  2. #2

    Default Re: What causes error code -37?

    In article <doit.wisc.edu>,
    Charles Thomas <facstaff.wisc.edu> wrote:
     

    Usually means you passing in a C string instead of a Pascal string. What name
    are you passing in?

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  3. #3

    Default Re: What causes error code -37?

    In article <mit.edu>,
    Miro Jurisic <org> wrote:
     
    >
    > Usually means you passing in a C string instead of a Pascal string. What name
    > are you passing in?[/ref]

    I'll list the basic steps I'm doing below.

    I get the -37 error thrown on the call to FSpCreate().

    //***** STEPS TO CREATE FILE

    err = NavGetDefaultDialogCreationOptions(&dialog_options );
    err = NavCreatePutFileDialog(&dialog_options, 'TEXT', 'ttxt', nil,
    nil, &the_dialog);
    err = NavDialogRun(the_dialog);
    err = NavDialogGetReply(the_dialog, &reply);
    err = AEGetNthPtr(&(reply.selection), 1, typeFSS, &keyword,
    &file_type, &fs_spec, sizeof(fs_spec), &file_size);
    NavDialogDispose(the_dialog);
    NavDisposeReply(&reply);
    err = FSpCreate(&fs_spec, 'ttxt', 'TEXT', smRoman);

    //*****

    CT
    Charles Guest

  4. #4

    Default Re: What causes error code -37?

    On Wed, 5 Nov 2003, Charles Thomas wrote:
     
    > >
    > > Usually means you passing in a C string instead of a Pascal string. What name
    > > are you passing in?[/ref]
    >
    > I'll list the basic steps I'm doing below.
    >
    > I get the -37 error thrown on the call to FSpCreate().[/ref]

    What are the actual contents of your FSSpec ?

    Fred.
     

    Frederick Guest

  5. #5

    Default Re: What causes error code -37?

    In article
    <srcf.societies.cam.ac.uk>
    ,
    Frederick Cheung <DUH.ucam.org> wrote:
     
    >
    > What are the actual contents of your FSSpec ?[/ref]


    Unfortunately, I'm not really sure. I cannot debug my application right
    now because even though it runs on OS9 it doesn't run yet on OSX, and
    that's the platform I'm using.

    Can you point me to likely problem areas? If so, I can throw the value
    of those variables out to the console so I can take a look at them
    (poor-man's debugging).

    CT
     
    >[/ref]
    Charles Guest

  6. #6

    Default Re: What causes error code -37?

    In article <doit.wisc.edu>,
    Charles Thomas <facstaff.wisc.edu> wrote:
     
    > >
    > > What are the actual contents of your FSSpec ?[/ref]
    >
    >
    > Unfortunately, I'm not really sure. I cannot debug my application right
    > now because even though it runs on OS9 it doesn't run yet on OSX, and
    > that's the platform I'm using.
    >
    > Can you point me to likely problem areas? If so, I can throw the value
    > of those variables out to the console so I can take a look at them
    > (poor-man's debugging).[/ref]

    The most likely problem area is the filename in the file spec.

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  7. #7

    Default Re: What causes error code -37?

    In article <doit.wisc.edu>,
    Charles Thomas <facstaff.wisc.edu> wrote:
     

    Usually it means that you're passing in some character that's not
    allowed in file names, i.e. a colon. This can also happen by accident,
    e.g. if your FSSpec has been overwritten by a bug in some other code
    you're using, or if you're passing in a string with a ed-up length
    byte, or if your FSSpec wasn't initialized. In some cases there also
    used to be reserved names, but I don't think that would give badNamErr
    anymore...

    It could also mean that the name is too long. Remember, a file name in
    an FSSpec can't be longer than 31 characters. For more you'll have to
    use an FSRef.

    Oh, and finally, since I see you're passing in smRoman: This should
    probably be something like smSystemScript or some other "meta-constant"
    or function call for the current script. I'm not sure whether passing in
    e.g. Japanese text might cause the OS to choke on this if you specify
    smRoman -- but I guess Japanese isn't what you're entering if you live
    in Wisconsin.

    Cheers,
    -- M. Uli Kusterer
    http://www.zathras.de
    Uli Guest

  8. #8

    Default Re: What causes error code -37?

    In article <t-online.com>,
    Uli Kusterer <de> wrote:
     
    >
    > Usually it means that you're passing in some character that's not
    > allowed in file names, i.e. a colon. This can also happen by accident,
    > e.g. if your FSSpec has been overwritten by a bug in some other code
    > you're using, or if you're passing in a string with a ed-up length
    > byte, or if your FSSpec wasn't initialized.[/ref]

    I'm getting the FSSpec from AEGetNthPtr(), so shouldn't it be
    initialized by that method? There's also nothing long or weird about
    the filename I'm typing into the NavDialog.

     

    Ok!

    CT
    Charles Guest

  9. #9

    Default Re: What causes error code -37?

    In article <doit.wisc.edu>,
    Charles Thomas <facstaff.wisc.edu> wrote:
     

    In the time it took you to type this up, you could have run this under the
    debugger and told us exactly what's in that FSSpec, so we can stop guessing.

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  10. #10

    Default Re: What causes error code -37?

    In article <mit.edu>,
    Miro Jurisic <org> wrote:
     
    >
    > In the time it took you to type this up, you could have run this under the
    > debugger and told us exactly what's in that FSSpec, so we can stop guessing.[/ref]

    As I said I can't debug this code because I'm running OSX and the app is
    in the process of being ported from OS9 to OSX.

    CT
    Charles Guest

  11. #11

    Default Re: What causes error code -37?

    On Fri, 7 Nov 2003, Charles Thomas wrote:
     
    > >
    > > In the time it took you to type this up, you could have run this under the
    > > debugger and told us exactly what's in that FSSpec, so we can stop guessing.[/ref]
    >
    > As I said I can't debug this code because I'm running OSX and the app is
    > in the process of being ported from OS9 to OSX.
    >[/ref]
    Stick in some code that will dump the contents to disk or the console.
    (and it might be worth looking at the results with a hex editor or
    something that will show you if there are crazy unprintables)

    Fred

    Frederick Guest

  12. #12

    Default Re: What causes error code -37?

    dans l'article doit.wisc.edu, Charles
    Thomas à facstaff.wisc.edu a écrit le 8/11/03
    0:14:
     
    >>
    >> In the time it took you to type this up, you could have run this under the
    >> debugger and told us exactly what's in that FSSpec, so we can stop guessing.[/ref]
    >
    > As I said I can't debug this code because I'm running OSX and the app is
    > in the process of being ported from OS9 to OSX.
    >
    > CT[/ref]

    If you're able to run Classic, then you're able to restart in OS9 and debug.

    Eric

    Eric Guest

  13. #13

    Default Re: What causes error code -37?

    In article <BBD1FD72.14FEE%fr>,
    Eric VERGNAUD <fr> wrote:
     

    What gave you that idea? There are several models that will run Classic
    but aren't bootable by 9.
    Gregory Guest

  14. #14

    Default Re: What causes error code -37?

    I was finally able to transfer my code and get it working (somewhat) on
    OSX for debugging.

    The problem seems to be that if I attempt to create a file called
    "MyTextFile.txt" in a folder called "Data" (for example), the FSSpec
    that's returned has simply "Data" in the filename variable, not
    Data/MyTextFile.txt".

    So it's returning the VOLUME and not the file in the FSSpec.

    Does that shed any light on what I might be doing wrong? The code in
    question follows

    CT


    ///====== CODE FOLLOWS

    err = NavGetDefaultDialogCreationOptions(&dialog_options );
    if (err != noErr)
    return(err);

    string_ref = CFStringCreateWithPascalString(kCFAllocatorDefault ,
    title, kCFStringEncodingASCII);
    dialog_options.windowTitle = string_ref;
    string_ref = CFStringCreateWithPascalString(kCFAllocatorDefault , msg,
    kCFStringEncodingASCII);
    dialog_options.message = string_ref;
    string_ref = CFStringCreateWithPascalString(kCFAllocatorDefault ,
    client_name, kCFStringEncodingASCII);
    dialog_options.clientName = string_ref;
    string_ref = CFStringCreateWithPascalString(kCFAllocatorDefault ,
    output_name, kCFStringEncodingASCII);
    dialog_options.saveFileName = string_ref;


    err = NavCreatePutFileDialog(&dialog_options, type_to_save,
    file_creator, nil, nil, &the_dialog);

    //*****Show the dialog to the user
    err = NavDialogRun(the_dialog);
    if (err != noErr)
    return(err);

    //***** Get the user reply
    err = NavDialogGetReply(the_dialog, &reply);
    if (err != noErr)
    return(err);

    if (!reply.validRecord)
    {
    *cancelled = true;
    return(noErr);
    }

    *replacing = reply.replacing;

    //****** Get the file information
    err = AEGetNthPtr(&(reply.selection), 1, typeFSS, &keyword,
    &file_type, fs_spec, sizeof(*fs_spec), &file_size);
    Charles Guest

  15. #15

    Default Re: What causes error code -37?

    Charles Thomas <facstaff.wisc.edu> wrote in message news:<doit.wisc.edu>... 

    (From: http://developer.apple.com/doentation/Carbon/Reference/Navigation_Services_Ref/navigation_services/data_type_7.html#//apple_ref/doc/c_ref/NavReplyRecord)

    "If you use the NavCreatePutFileDialog function, this descriptor
    specifies the directory where the file is to be saved. "

    It sounds like the FSSpec returned is the FSSpec of the FOLDER to
    which you want to save. If you use this to create the new file, you're
    trying to overwrite a folder with your new file which will cause an
    error.

    HTH,
    Mike.
    Mike Guest

  16. #16

    Default Re: What causes error code -37?

    In article <google.com>,
    utvinternet.com (Mike Whooley) wrote:
     

    It sounds like what I need to do is copy the name in reply.saveFileName
    (a CFStringRef) into the fs_spec.name field.

    I'm not very familar with CFStringRef objects. What's the best way to
    do this copying?

    CT
    Charles Guest

  17. #17

    Default Re: What causes error code -37?

    On Wed, 12 Nov 2003, Charles Thomas wrote:
     
    >
    > It sounds like what I need to do is copy the name in reply.saveFileName
    > (a CFStringRef) into the fs_spec.name field.[/ref]

    No you don't. that would be a fsspec to an object called
    reply.saveFileName and in the same folder as what you have got out of the
    NavReplyRecord, instead of inside that folder.
     
    CFStringGetPascalString will do the job (although i'd encourage you to
    ditch the fsspecs and use fsrefs instead).

    Fred

    Frederick Guest

  18. #18

    Default Re: What causes error code -37?

    In article
    <srcf.societies.cam.ac.uk>,
    Frederick Cheung <DUH.ucam.org> wrote:
     

    Copying the name with CFStringGetPascalString is wrong. Do not do that. You need
    to carry the parent folder and the CFString name to the place where you will
    create the file, and then create the file using FSRef APIs.

    meeroh

    --
    If this message helped you, consider buying an item
    from my wish list: <http://web.meeroh.org/wishlist>

    Miro Guest

  19. #19

    Default Re: What causes error code -37?

    Charles Thomas <facstaff.wisc.edu> wrote:
     
    >
    > As I said I can't debug this code because I'm running OSX and the app is
    > in the process of being ported from OS9 to OSX.[/ref]

    You can
    - run a copy of the CWP 8 IDE in Classic in order to debug
    - install MacsBug in Classic and insert an DebugStr in you code.

    HTH,
    Tom_E

    --
    This address is valid in its unmodified form but expires soon.

    Thomas Guest

Similar Threads

  1. Template error code 3 + Error Accessing files..
    By Kenny Tew in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: June 30th, 04:17 AM
  2. Error some where in code.
    By lazerbrains555 in forum Macromedia ColdFusion
    Replies: 7
    Last Post: March 24th, 09:07 PM
  3. db2 sql error code ref
    By xixi in forum IBM DB2
    Replies: 1
    Last Post: August 6th, 05:52 PM
  4. Code Behind vs. no code behind: error
    By Ben Miller [msft] in forum ASP.NET General
    Replies: 1
    Last Post: June 28th, 01:46 AM

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