Space at end of dirname

Advertisement

Pascal
Guest

Space at end of dirname

Hi,

When the name of remote directory ends with a space character, the transfert from remote to local make an error "Can't create file 'C:\SpaceDirName \testfile.pdf'.

I'm using WinSCP 3.8.2 (build 330) / SFTP protocole with Norton Commander style.

. 2007-04-24 13:55:34.062 Copying "/xmap/xx xxxxxxx/XMAP /1ETAT1.FRX" to local directory started.
. 2007-04-24 13:55:34.062 Binary transfer mode selected.
* 2007-04-24 13:55:34.062 (ExtException)
. 2007-04-24 13:55:34.062 Asking user:
. 2007-04-24 13:55:34.062 Can't create file 'C:\Documents and Settings\Administrateur\Mes documents\XMAP \1ETAT1.FRX'. ()


This "bug" occurs in WinSCP 4.0 beta.

Reply with quote

Advertisement

Pascal
Guest

Hi,

First, thanks for answer and the very good job.
Effectivly, Window$ "rename" directory if it ends with a space.
But, if the remote directory ~ on Linux ~ ends with, the transfert shutdown.
May be it will be possible to avoid this problem?
- replace spaces in dirname by something else,
- (and/or) inform the user
...

Reply with quote

martin
Site Admin
martin avatar

Pascal wrote:

- replace spaces in dirname by something else,
There can be spaces, but not at the end. WinSCP may trim them. I'll consider that.

Reply with quote

TS
Guest

Windows does actually allow spaces at the end of file names. The limitation, as with so many other things, is that the file-ending-in-space has to be created/manipulated through the command prompt, as explorer automatically trims spaces.

C:\temp>copy con "foo.txt "
Hello there
^Z
        1 file(s) copied.

C:\temp>type "foo.txt "
Hello there

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

TS wrote:

Windows does actually allow spaces at the end of file names. The limitation, as with so many other things, is that the file-ending-in-space has to be created/manipulated through the command prompt, as explorer automatically trims spaces.
This doesn't seem to be true. At least on WinXP. The command line also trim spaces. It trims that both for "copy" and "type", that's why your commands work. Actual file name is "foo.txt" (without space).

Reply with quote

TS
Guest

martin wrote:

... Actual file name is "foo.txt" (without space).

True enough, I created a poor example. My apologies. Here's a better (functional!) example:

C:\Temp>copy con "\\?\C:\temp\foo.txt "
blah blah
^Z
        1 file(s) copied.

C:\Temp>dir foo.txt
 Volume in drive C has no label.
 Volume Serial Number is 28BC-75F3

 Directory of C:\Temp

File Not Found

C:\Temp>dir f*
 Volume in drive C has no label.
 Volume Serial Number is BARF-FARB

 Directory of C:\Temp

05/02/2007  11:49 PM                11 foo.txt
               1 File(s)             11 bytes
               0 Dir(s),555,555,555,555 bytes free

C:\Temp>type "\\?\C:\temp\foo.txt "
blah blah

C:\Temp>

You are correct that the Win32 CreateFile() API strips spaces. I think files ending in space may not be "officially supported" by Microsoft, but I'm not sure about that.

Reply with quote

Advertisement

You can post new topics in this forum