• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CURLHandle and making directories on remote host
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CURLHandle and making directories on remote host


  • Subject: Re: CURLHandle and making directories on remote host
  • From: m <email@hidden>
  • Date: Sun, 1 Feb 2004 16:20:08 -0600

Ok, I've puzzled out a solution.

Either CURLHandle doesn't provide an API for using CURLOPT_QUOTE or I'm just not seeing it. Anyhow, this bit of code works (assumes the presence of CURLHandle.framework):



#import "CURLHandle/CURLHandle.h"

- (NSString*) makeDirectory: (NSString*)inDirectoryName // eg. @"myNewDirectory"
inParentDirectory: (NSString*)inParentDirectory // eg. @"existingDirectory1/existingDirectory2"
ofHost: (NSString*)inFTPHost // eg.@"ftp://myusername:email@hidden
{
NSString* errorString = nil;
NSString* urlString = inFTPHost;
NSURL* url = [NSURL URLWithString:urlString];
CURLHandle* urlHandle = (CURLHandle *)[url URLHandleUsingCache:NO];
CURLcode curlCode = CURLE_OK;

struct curl_slist* list = nil;

if (inParentDirectory)
{
const char* cwdString = [[NSString stringWithFormat:@"CWD %@", inParentDirectory]cString];
list = curl_slist_append(list, cwdString);
}

const char* mkdString = [[NSString stringWithFormat:@"MKD %@", inDirectoryName]cString];
list = curl_slist_append(list, mkdString);

curlCode = curl_easy_setopt([urlHandle curl], CURLOPT_QUOTE, list);
if (curlCode == CURLE_OK)
{
[urlHandle prepareAndPerformCurl];

curl_slist_free_all(list);

errorString = [urlHandle curlError];
if (errorString && [errorString length] > 0)
{
NSLog([urlHandle curlError]);
}
}

return errorString;
}

Regards,

_murat

On Feb 1, 2004, at 4:49 AM, m wrote:

I've been beating my head against the wall trying to figure out how to properly create a directory on an FTP host using CURLHandle.

Basically, I want to emulate the following terminal command:

curl -Q "MKD somedirectory" ftp://myusername:email@hidden

which when invoked in Terminal, results in a directory named "somedirectory" on the FTP host.


Here's how I'm trying to do it using CURHandle:

NSString* urlString = @"ftp://myusername:email@hidden";;
NSURL* url = [NSURL URLWithString:urlString];
CURLHandle* urlHandle = (CURLHandle *)[url URLHandleUsingCache:NO];

[urlHandle setString:@"MKD somedirectory" forKey:CURLOPT_QUOTE];
[urlHandle prepareAndPerformCurl];

The result when running this code is that as soon as I execute the last line, I get a EXC_BAD_ACCESS. Note that I am able to successfully upload files using CURLHandle, so I'm pretty sure the CURLHandle.framework is properly installed and initialized.

Any help appreciated.

Regards,

_murat
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Updating text fields in Cocoa. (From: Daniel Todd Currie <email@hidden>)
 >CURLHandle and making directories on remote host (From: m <email@hidden>)

  • Prev by Date: Re: Cocoa/Windows parallel dvlpmt
  • Next by Date: Strange KVC behavior between 10.2 and 10.3 (bug ?)
  • Previous by thread: CURLHandle and making directories on remote host
  • Next by thread: Populating a pulldown menu
  • Index(es):
    • Date
    • Thread