Recent

Author Topic: Howe determine if filesystem is case sensitive?  (Read 279 times)

Borneq

  • Full Member
  • ***
  • Posts: 207
Howe determine if filesystem is case sensitive?
« on: December 07, 2019, 10:55:41 pm »
I am comparing paths using CompareText or CompareStr depend if is case sensitive filesystem.
Worse solution: what are conditionals for Windows, Linux and other case-sensitive, insensitive systems?
But it is not quite good: in Linux can I read Fat32 or NTFS, while is case insensitive, better would be ask for directory, for example '.' and determine sensitivity.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7801
Re: Howe determine if filesystem is case sensitive?
« Reply #1 on: December 07, 2019, 11:01:21 pm »
Afaik FPC does not deal with this on a file system basis, only with global variables FileNameCaseSensitive and FileNameCasePreserving

jamie

  • Hero Member
  • *****
  • Posts: 2248
Re: Howe determine if filesystem is case sensitive?
« Reply #2 on: December 07, 2019, 11:02:02 pm »
Write to temp files, one with Upper case the other as lower.. See if you get a file error when writing the second  :)
Number 1 at blue screen app creations!

winni

  • Hero Member
  • *****
  • Posts: 709
Re: Howe determine if filesystem is case sensitive?
« Reply #3 on: December 07, 2019, 11:06:22 pm »
Or the other way round:

Write filename  "MyFile"

Check if " MYFILE" exists.


PascalDragon

  • Hero Member
  • *****
  • Posts: 849
  • Compiler Developer
Re: Howe determine if filesystem is case sensitive?
« Reply #4 on: December 08, 2019, 11:30:49 am »
I am comparing paths using CompareText or CompareStr depend if is case sensitive filesystem.
Worse solution: what are conditionals for Windows, Linux and other case-sensitive, insensitive systems?
But it is not quite good: in Linux can I read Fat32 or NTFS, while is case insensitive, better would be ask for directory, for example '.' and determine sensitivity.
Well, things have gotten even more complicated regarding that, because NTFS nowadays (Windows 10) supports per directory case sensitivity (for WSL) and Ext4 recently gained support for per directory case insensitivity...

ASBzone

  • Sr. Member
  • ****
  • Posts: 282
  • Automation leads to relaxation...
    • BrainWaveCC Utilities
Re: Howe determine if filesystem is case sensitive?
« Reply #5 on: December 08, 2019, 07:34:53 pm »
I am comparing paths using CompareText or CompareStr depend if is case sensitive filesystem.
Worse solution: what are conditionals for Windows, Linux and other case-sensitive, insensitive systems?
But it is not quite good: in Linux can I read Fat32 or NTFS, while is case insensitive, better would be ask for directory, for example '.' and determine sensitivity.


What is your actual use case?

Why not always check using the case sensitive function?


-ASB
-ASB: https://www.BrainWaveCC.com

Lazarus v2.0.7 r62558 / FPC v3.2.0-beta-r43958 (via FpcUpDeluxe) -- Windows 64-bit install w/32-bit cross-compile
Primary System: Windows 10 Pro x64, Version 1909 (Build 18363.592)
Other Systems: Windows 10 Pro x64, Version 1909 or greater