lhmouse / nano-win

GNU nano text editor for Windows [WARNING: The master branch is constantly rebased and force-pushed so don't expect it to be steady!! -end WARNING]
https://files.lhmouse.com/nano-win/
GNU General Public License v3.0
210 stars 25 forks source link

Cannot Backup To Backupdir If Set #19

Closed gangsterofboats closed 3 years ago

gangsterofboats commented 3 years ago

If backupdir is set to, I think, any Windows path, Nano cannot backup to that path, but will write to the Home directory instead. Looking at the source, though not really being good at C, I think the problem lies about lines 1420 to 1430 in the files.c file. It only replaces the slashes in the path, but Windows also cannot have colons in filenames.

lhmouse commented 3 years ago

There are actually a few more issues on this:

  1. get_full_path() should return a path with forwardslashes instead of backslashes (note other code doesn't check for forwardslashes at all).
  2. When checking for relative paths, dirname[0] != '/' does not work on Windows. PathIsRelativeA() is suggested.
  3. Not only are colons disallowed, but also <>:"/\|?*, as well as all control characters.

I am working on a fix at the moment.

lhmouse commented 3 years ago

Fixed and uploaded: https://files.lhmouse.com/nano-win/nano-win_9371_v5.4-9-gef33c2a8.7z

gangsterofboats commented 3 years ago

Thanks.

lhmouse commented 3 years ago

The previous build may crash or hang if the backupdir is set to a path ending with a slash (forward or backward). A new build has been uploadad: https://files.lhmouse.com/nano-win/nano-win_9371_v5.4-9-g8ad13081.7z