Compare is not detecting upper and lower case.

Discussion of bugs and problems found in Altap Salamander. In your reports, please be as descriptive as possible, and report one incident per report. Do not post crash reports here, send us the generated bug report by email instead, please.
jorgerhv
Posts: 6
Joined: 13 Dec 2005, 01:06

Compare is not detecting upper and lower case.

Post by jorgerhv »

The Compare Directories menu says there are not differences :

My_BoxedIn_A_15
My_Boxedin_A_15

Is normal behavior ?

Brett
Posts: 20
Joined: 05 Nov 2008, 13:45

Re: Compare is not detecting upper and lower case.

Post by Brett »

The Windows OS is case insensitive (unlike Linux) so I would assume this is normal behaviour.

User avatar
tukanos
Posts: 347
Joined: 21 Dec 2005, 19:14

Re: Compare is not detecting upper and lower case.

Post by tukanos »

This is not a windows issue.

If you want to differentiate between cases you have to click on advanced options and click on checkbox 'Case'. Then you will get correct result.

User avatar
mdruiter
Posts: 260
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Re: Compare is not detecting upper and lower case.

Post by mdruiter »

I'm sorry but tukanos is incorrect. When comparing file contents, one can choose to include case. Filename comparisons are case INsensitive due to the nature of Windows.

A workaround could be saving the filenames into files (say via Ctrl+Shift+F6) and comparing those.

User avatar
tukanos
Posts: 347
Joined: 21 Dec 2005, 19:14

Re: Compare is not detecting upper and lower case.

Post by tukanos »

mdruiter wrote:I'm sorry but tukanos is incorrect. When comparing file contents, one can choose to include case. Filename comparisons are case INsensitive due to the nature of Windows.

A workaround could be saving the filenames into files (say via Ctrl+Shift+F6) and comparing those.
No need to be sorry. When I say something I usually have a proof what I'm saying. Most windows are indeed case insensitive, however, NTFS can differentiate between cases (I presume NTFS is the most used filesystem in the windows environment). Now question is if AS is capable of doing so that is probably the issue here. I was wrong to expect such thing from AS when the issue is using it from C/C++ runtime.

I'll quote stockoverflow at http://stackoverflow.com/questions/7199 ... ve#7200533

Case sensitivity on Windows is actually implemented in how the application opens the files. NTFS can be a case-sensitive file system and can happily store files, with identical names differing only by case in the same directory.

On Windows all files are ultimately opened via the CreateFile API - If the FILE_FLAG_POSIX_SEMANTICS flag is passed to the call (and the file system being accessed is natively case-sensitive) then the file will be opened based on an exact name match. If FILE_FLAG_POSIX_SEMANTICS is not passed then the filesystem does a case-insensitive file open and will open one of the files with a matching name. If there is more than one it's undefined as to which one is actually opened.

Most C and C++ runtime implementations on Windows do not provide any access to this mechanism and never use this flag so the only way to get access to case-sensitive behaviors is to use the Windows API directly.

User avatar
mdruiter
Posts: 260
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Re: Compare is not detecting upper and lower case.

Post by mdruiter »

I'm aware that NTFS is case sensitive and there is an API to use that feature. But Windows is case insensitive in nature: the Win32 API by default and the shell, both CMD and Explorer. So I can understand that Salamander does what Windows users expect: compare filenames without regard to case. Even though it can be cumbersome when interacting with other OSes, e.g. via FTP or SMB.

In any case I don't see Advanced options nor a Case checkbox in Salamander when comparing filenames.
Last edited by mdruiter on 03 Apr 2017, 15:39, edited 1 time in total.

User avatar
tukanos
Posts: 347
Joined: 21 Dec 2005, 19:14

Re: Compare is not detecting upper and lower case.

Post by tukanos »

mdruiter wrote:I'm aware that NTFS is case sensitive and there is an API to use that feature. But Windows is case insensitive in nature: the Win32 API by default and the shell, both CMD and Explorer. So I can understand that Salamander does what Windows users expect: compare filenames without regard to case. Even though it can be cumbersome when interacting with other OSes, e.g. via FTP or SMB.

I any case I don't see Advanced options nor a Case checkbox in Salamander when comparing filenames.
It took me quite a while to investigate this issue as it got me quite interested. The answer is not at all trivial.

As you may know there are different layers to operating system (kernel, filesystem, drivers, user-space (where you have Win32 API), etc.). Now how do the different parts of Windows behave when considering case sensitivity? If Windows would be completely case insensitive or how you said "Windows is case insensitive in nature" there would not be a way for the kernel to know or use any windows tools to find out the casing on native NTFS file sytem, which is not the case (I'll demonstrate it later in this post).

When comparing filenames (alias File comparator) you have to see it, but not comparing directories (which was the original question - and I got it mixed files/directories, that was my mistake I admit).
File_compare_casing.jpg
File_compare_casing.jpg (258.78 KiB) Viewed 7092 times
First lets talk about kernel. The default setting is case insensitivity. Is there a way to switch it on? (Warning: do not try this on production system it may damaged it!). Actually there is!
If you change the following settings the kernel will be, after reboot, case sensitive:
registry_kenrel_case_sensitivity.jpg
registry_kenrel_case_sensitivity.jpg (170.45 KiB) Viewed 7092 times
I don't have yet a windows 7 virtual machine to try it out, it would be interesting to see how Salamander behaves under such conditions. I'm pretty sure that win32-api applications like windows explorer will not like it.

Back to the original question:
The Compare Directories menu says there are not differences :

My_BoxedIn_A_15
My_Boxedin_A_15

Is normal behavior ?
In my eyes this is not normal behavior, but it is currently beyond AS. The AS developers would have to add an regexp option for you to be able to search among casings.

I tried to "hack" another tool for that purpose and that was a batch renamer - that would show you a result in the preview screen, however it is useful only for filename differentiation.

So are there other options (without the kernel knowing? The default settings). Fortunately it appear that yes.

First approach was to use native tools in the command-line like findstr:

Code: Select all

findstr /S /R "^[A-Z].*$"
However that did not work properly, probably as findstr is full of bugs (see more on stackowerflow topics)

Then I said to myself, having the Unix extension installed of windows maybe linux tools (as they are all POSIX compliant) should work, I don't know the reason but

Code: Select all

grep -r -G "^[A-Z].*$" 
did not work either.

So as last resort I told my self to go to powershell, which worked excellently:
powershell_case_sensitive.jpg
powershell_case_sensitive.jpg (101.35 KiB) Viewed 6998 times

Code: Select all

Get-ChildItem -Recurse | Select-Object FullName | select-string -pattern "[h,j]" -CaseSensitive
In pattern you can use regexp or simple string like "hello".
powershell_case_sensitive_example_with_files_and_directories.jpg
powershell_case_sensitive_example_with_files_and_directories.jpg (34.79 KiB) Viewed 7092 times
If you want to get only directories you can do:

Code: Select all

Get-ChildItem -Recurse -Directory| Select-Object FullName | select-string -pattern "[h,j]" -CaseSensitive
and you will get:
powershell_case_sensitive_example_with_directories_only.jpg
powershell_case_sensitive_example_with_directories_only.jpg (24.06 KiB) Viewed 7092 times
Is there a GUI tool to be used which can identify casing? Yes there is.
Please see http://locate32.cogit.net/. The only disadvantage is that you have to build a database prior searching. Otherwise than that it is really good tool.

Thank you mdruiter for getting me interested.
Last edited by tukanos on 04 Apr 2017, 09:19, edited 1 time in total.

therube
Posts: 634
Joined: 14 Dec 2006, 06:22

Re: Compare is not detecting upper and lower case.

Post by therube »

Locate32 -> Everything 1.4.1 Beta.

Image


(The directory where I "install" Everything is named, Locate ;-).)
(C:\DEV\Locate\Everything.exe)
WinXP Pro SP3 or Win7 x86 | SS 2.54

User avatar
tukanos
Posts: 347
Joined: 21 Dec 2005, 19:14

Re: Compare is not detecting upper and lower case.

Post by tukanos »

therube wrote:Locate32 -> Everything 1.4.1 Beta.

Image


(The directory where I "install" Everything is named, Locate ;-).)
(C:\DEV\Locate\Everything.exe)
I see, thank you for the update :). I was wondering if they changed the name but did not search further as I did not need it at the moment.

therube
Posts: 634
Joined: 14 Dec 2006, 06:22

Re: Compare is not detecting upper and lower case.

Post by therube »

(Two separate products that do similar functions. Locate32, while great - in its time, since outdistanced by Everything.
And that said, each servers a purpose.)
WinXP Pro SP3 or Win7 x86 | SS 2.54

User avatar
tukanos
Posts: 347
Joined: 21 Dec 2005, 19:14

Re: Compare is not detecting upper and lower case.

Post by tukanos »

therube wrote:(Two separate products that do similar functions. Locate32, while great - in its time, since outdistanced by Everything.
And that said, each servers a purpose.)
Thank you for directing me to Everything, works great.

Post Reply