Topic "Space at end of dirname"

Author Message
Pascal

Guest


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.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
On Windows, file or directory cannot end with space.
_________________
Martin Prikryl
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
...
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
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.
_________________
Martin Prikryl
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.

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

C:\temp>type "foo.txt "
Hello there
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
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).
_________________
Martin Prikryl
TS

Guest


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


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

Code:
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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
This issue has been added to tracker.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License