Filesize, OpenFile not case sensitive is Not a bug.

Just starting out? Need help? Post your questions and find answers here.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Filesize, OpenFile not case sensitive is Not a bug.

Post by collectordave »

MAC OS 10.14.6

PB 5.73 LTS


I do not know if this is a bug or not.

FileSize() and OpenFile are not case sensitive.

Using the following code:-

Code: Select all

Macro FileExists1(filename)
    Bool(FileSize(fileName) > -1)
 EndMacro
  
  
 Procedure.I FileExists2(Filename.S)
  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_Windows
      ProcedureReturn PathFileExists_(Filename)
    CompilerCase #PB_OS_Linux
      Protected UTF8Filename.S = Space(StringByteLength(Filename, #PB_UTF8) + 1)
      PokeS(@UTF8Filename, Filename, -1, #PB_UTF8)
      ProcedureReturn g_file_test_(UTF8Filename, #G_FILE_TEST_EXISTS)
    CompilerCase #PB_OS_MacOS
      ProcedureReturn CocoaMessage(0, CocoaMessage(0, 0,
        "NSFileManager defaultManager"),
        "fileExistsAtPath:$", @Filename)
  CompilerEndSelect
EndProcedure 
  
Define MyOpenFile.i,MyGoodFile.s,MyBadFile.s
  
  
MyGoodFile = GetUserDirectory(#PB_Directory_Documents) + "TI Media/A Place To Bury Strangers/" + "A Place To Bury Strangers - I Lost You.ogg"  


MyBadFile = GetUserDirectory(#PB_Directory_Documents) + "TI Media/A Place to Bury Strangers/" + "A Place to Bury Strangers - I Lost You.ogg"  


Debug MyGoodFile

Debug FileSize(MyGoodFile)

Debug FileExists1(MyGoodFile)

Debug FileExists2(MyGoodFile)

MyOpenFile = OpenFile(#PB_Any,MyGoodFile)

Debug MyOpenFile

CloseFile(MyOpenFile)

Debug MyBadFile

Debug FileSize(MyBadFile)

Debug FileExists1(MyBadFile)

Debug FileExists2(MyBadFile)

MyOpenFile = OpenFile(#PB_Any,MyBadFile)

Debug MyOpenFile

CloseFile(MyOpenFile)

Both filenames return the same they both exist and they can both be opened but only the MyGoodFile actual exists.

The difference is the lower case t in the baffle name.

Makes Filesize etc unreliable.

CD
Last edited by collectordave on Thu Mar 25, 2021 7:12 am, edited 1 time in total.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Filesize, OpenFile Bug?

Post by collectordave »

After a little bit more trial and error.

The file system is case insensitive by default so not a PB bug.

The file system can be made case sensitive but is definatly not recommended as some applications will not work properly with a case sensitive file system.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Filesize, OpenFile not case sensitive is Not a bug.

Post by Shardik »

Case sensitivity on MacOS volumes depends on the partition format of that volume. You can simply query the MacOS partition format with this console command (which you may even run from a PureBasic program with RunProgram()):

Code: Select all

diskutil info "/Volumes/NameOfYourVolume" | grep "User Visible"
Beginning with MacOS 10.13 'High Sierra' you may get these results:
  • APFS
  • APFS (Encrypted)
  • APFS (Case-sensitive)
  • APFS (Case-sensitive, Encrypted)
On older MacOS volumes you will get these results:
  • MacOS Extended (Journaled)
  • MacOS Extended (Journaled, Encrypted)
  • MacOS Extended (Case-sensitive, Journaled)
  • MacOS Extended (Case-sensitive, Journaled, Encrypted)
On non-MacOS volumes (for example BOOTCAMP):
  • Windows NT File System (NTFS)
Or ExFAT:
  • ExFAT
User avatar
NicTheQuick
Addict
Addict
Posts: 1226
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Filesize, OpenFile Bug?

Post by NicTheQuick »

collectordave wrote:The file system can be made case sensitive but is definatly not recommended as some applications will not work properly with a case sensitive file system.
Well, on Linux it is always case sensitive and I like it. I also don't know any application which has problems with that.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Filesize, OpenFile not case sensitive is Not a bug.

Post by Shardik »

NicTheQuick wrote:Well, on Linux it is always case sensitive and I like it. I also don't know any application which has problems with that.
On MacOS the default is case-insensitivity. If you format a Mac partition with case-sensitivity you may run into trouble with third party software:
[color=#0040FF][u]MacWorld[/u][/color] wrote:However, some Mac software—notably that made by Adobe and Valve—balks at case sensitivity.
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Filesize, OpenFile not case sensitive is Not a bug.

Post by TI-994A »

collectordave wrote:FileSize() and OpenFile are not case sensitive.
All functions in the FileSystem library correspond directly to the underlying file system of the OS. This includes case sensitivity.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Post Reply