Professional Web Applications Themes

HTTP and porting Win -> Mac OS X - Mac Programming

I have a software package, developed for Windows, which I'd like to port to Mac OS X. However, it uses one important Windows function, called downloadurl: HRESULT URLDownloadToFile( LPUNKNOWN pCaller, LPCSTR szURL, LPCSTR szFileName, DWORD dwReserved, LPBINDSTATUSCALLBACK lpfnCB ); The downloadurl function takes a URL and a filename etc as input and downloads the file which the URL points at to disk (using the disk path and name given as the first argument). It also performs MIME decoding so the doent downloaded is not just the MIME encoded text but can be a binary file, e.g. a GIF or an ...

  1. #1

    Default HTTP and porting Win -> Mac OS X

    I have a software package, developed for Windows, which I'd like to port
    to Mac OS X. However, it uses one important Windows function, called
    downloadurl:

    HRESULT URLDownloadToFile(
    LPUNKNOWN pCaller,
    LPCSTR szURL,
    LPCSTR szFileName,
    DWORD dwReserved,
    LPBINDSTATUSCALLBACK lpfnCB
    );


    The downloadurl function takes a URL and a filename etc as input and
    downloads the file which the URL points at to disk (using the disk
    path and name given as the first argument). It also performs
    MIME decoding so the doent downloaded is not just the MIME
    encoded text but can be a binary file, e.g. a GIF or an MP3 file.

    Is there a similar function on Mac OS X?

    How can a similar function be provided on Mac OS X (except writing
    it myself from scratch, which is a bit of work considering it should
    do MIME decoding as well)?

    I'm on 10.2.8 and use the Project Builder (C++).

    Thanks
    Mikael


    Mike Guest

  2. #2

    Default Re: HTTP and porting Win -> Mac OS X

    dans l'article drylb.30666$telia.net, Mike à
    com a écrit le 22/10/03 18:41:
     

    Have a look at URLOpen etc...

    Eric

    Eric Guest

  3. #3

    Default Re: HTTP and porting Win -> Mac OS X


    "Eric VERGNAUD" <fr> wrote: 
    >
    > Have a look at URLOpen etc...
    >
    > Eric[/ref]

    It might be exactly what I need if it does MIME decoding. The docs don't say
    anything about that. Do you know if it does? I could always try and see of course.

    Thanks anyway
    M



    Mike Guest

  4. #4

    Default Re: HTTP and porting Win -> Mac OS X

    >> Have a look at URLOpen etc... 
    >
    > It might be exactly what I need if it does MIME decoding. The docs don't say
    > anything about that. Do you know if it does? I could always try and see of
    > course.
    >[/ref]

    I have no clue. I use it over ftp.

    Eric Guest

  5. #5

    Default Re: HTTP and porting Win -> Mac OS X

    In article <drylb.30666$telia.net>,
    "Mike" <com> wrote:
     

    If you're writing in Cocoa this is broken up into two methods:
    you download the data pointed to by an NSURL into a data object:

    + (id) dataWithContentsOfURL: (NSURL *) aURL

    If you are going to look at the data returned as if it's text,
    you can download it straight into a string:

    + (id) stringWithContentsOfURL: (NSURL *) aURL

    Mostly, you just look at the data there, without actually
    bothering to save it into a file and reading it out again. The
    system takes care of cacheing and memory-handling for big
    objects for you, of course.

    If you do actually want to save the results into a file, you
    just add one other call. For a string object you'd do this:

    - (BOOL) writeToFile: (NSString *) path atomically: (BOOL) flag

    Where 'path' is the file path, and 'atomically' is a flag which
    you set to tell OS X to do its file-swapping trick (write to a
    file in temporary space rename it to make the new file iff the
    entire read/write process worked without errors).

    If you're not using Cocoa, you should look at the Core
    Foundation functions surrounding CFURL. I don't know much about
    them.
     

    That may or may not be done by the above function, I'm not sure.
    The heavy hacking for MIME classes is done within NSURLResponse
    but I'm not sure if the object routines actually do all this for
    you automatically. It looks like the best Cocoa doentation for
    this stuff is all off of

    /Developer/Doentation/Cocoa/TasksAndConcepts/ProgrammingTopics/URLResources/index.html

    I do know that it handles encodings (i.e. Windows code-page,
    Unicode, Cyrillic, etc.) correctly and returns a string of a
    usable type no matter what encoding was used on the web page.


    Simon Guest

  6. #6

    Default Re: HTTP and porting Win -> Mac OS X

     

    Thanks. I'll check it.

    M


    Mike Guest

Similar Threads

  1. Porting from CS to 10... can it work?
    By JeffreyBower@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 3
    Last Post: April 13th, 03:40 PM
  2. porting to windows NT
    By Shaunn Johnson in forum PERL Beginners
    Replies: 3
    Last Post: January 30th, 02:26 PM
  3. Help need to porting from MS SQL to DB2 8.1
    By James Hong in forum IBM DB2
    Replies: 5
    Last Post: September 25th, 09:29 AM
  4. porting to pc
    By cwf prod webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 1
    Last Post: August 12th, 02:56 PM
  5. Porting code to Mac
    By Stephen Fraser in forum Mac Programming
    Replies: 2
    Last Post: August 3rd, 04:16 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