cURL / Mailing Lists / curl-library / Single Mail

curl-library

How to consistently CWD to HOME directory before using MKD command

From: Bill Middlecamp <Bill.Middlecamp_at_quantum.com>
Date: Thu, 20 Sep 2012 15:50:25 +0000

With some FTP servers, libcurl does not CWD to the home directory, and that creates a problem with the MKD command.

I am trying to create a unique directory at the end of possibly existing path. For example:

foo/bar/unique.1234

1) The "foo/bar" portion of the path may or may not exist, so I use MULTICWD together with the upload of a temporary file to get libcurl to create those directories if needed. Then I DELE the temporary file with a POSTQUOTE command.

2) Next, I change to NOCWD, and expect that this will produce a CWD to the HOME directory.

3) Finally, I use "MKD foo/bar/unique.1234". This will fail if the directory exists, so then I do "MKD foo/bar/unique.1235", and so on until the MKD succeeds, or until it fails 10 times.

The problem is that with some FTPD servers the CWD to HOME is not occurring. This causes the MKD to attempt to create the path "foo/bar/foo/bar/unique.1234".

The problem cannot be fixed by adding '/' to the start of the MKD path because the FTP user's HOME may not be '/', and that causes problems.

The FTP server where it fails to CWD to HOME produces this response to PWD immediately following login:

257 Current directory is: "/"

The FTP server where it succeeds produces this:

257 "/work/z1/bmiddlec/xfer" is your current location

I am using libcurl version 7.25.0

How can I code this to work for all FTP servers?

Bill Middlecamp

----------------------------------------------------------------------
The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-20