Recent

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

Borneq

  • Full Member
  • ***
  • Posts: 248
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

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
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: 6090
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  :)
The only true wisdom is knowing you know nothing

winni

  • Hero Member
  • *****
  • Posts: 3197
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: 5446
  • 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

  • Hero Member
  • *****
  • Posts: 678
  • Automation leads to relaxation...
    • Free Console Utilities for Windows (and a few for Linux) from BrainWaveCC
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.2.7-ada7a90186 / FPC v3.2.3-706-gaadb53e72c
(Windows 64-bit install w/Win32 and Linux/Arm cross-compiles via FpcUpDeluxe on both instances)

My Systems: Windows 10/11 Pro x64 (Current)

 

TinyPortal © 2005-2018