Problems with directories names which end with a trailing space

Here can you find the answer to many questions. Please, read first before posting. This forum is read only.
Post Reply
User avatar
cobian
Site Admin
Posts: 4966
Joined: 31 Oct 2020, 01:25
Location: Sweden
Contact:

Problems with directories names which end with a trailing space

Post by cobian »

I see some errors while trying to backup some directory or file with a name that ends with a trailing space, for example: ""C:\My directory ";

This is a limitation of the Windows Api. The file system supports those kind of names (and tose are files that often are created by MacOS".

From MSDN "Naming Files, Paths, and Namespaces (Windows)":
Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not.

Problems can arise when a Macintosh client creates a file on a Windows NT server. The code to remove trailing spaces and periods is not carried out and the Macintosh user gets the correctly punctuated filename. The Win32 APIs FindFirstFile() and FindNextFile() return a filename that ends in a space or in a period; however, there is no way to create or open the file using the Win32 API.
So this will be causing a lot of errors, caused by Windows API.
--
--
Luis Cobian
Cobian Backup's creator
Post Reply