I have been trying to write a program in which a hidden file is created for storing numbers used by the program the next time it is run. I currently am testing on a Mac OSX (PowerPC) and Windows XP Pro (x86). This is what I have tried with no success:
If #PB_Compiler_OS = #PB_OS_Windows
OpenFile(3,ProgPath + "Loc.txt")
SetFileAttributes(ProgPath + "Loc.txt",#PB_FileSystem_Hidden)
ReadFile(3, ProgPath + "Loc.txt")
Else
OpenFile(3,ProgPath + ".Loc.txt")
ReadFile(3, ProgPath + ".Loc.txt")
EndIf
The above code works for WinXP(x86), but the Mac OSX (PowerPC) says:
"[14:34:15][COMPILER] Line 44: Constant not found. #PB_FileSystem_Hidden."
I also tried this to no avail:
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
OpenFile(3,ProgPath + "Loc.txt")
SetFileAttributes(ProgPath + "Loc.txt",#PB_FileSystem_Hidden)
ReadFile(3, ProgPath + "Loc.txt")
CompilerElse
OpenFile(3,ProgPath + ".Loc.txt")
ReadFile(3, ProgPath + ".Loc.txt")
CompilerEndIf
Now the Mac OSX (PowerPC) says the Classic Environment is no longer supported.
I have search tirelessly over this and other forums.
Please help.
Thank you.
-Peter (peterowe3)
PS- I have been using PureBasic 4.51 for Windows (x86). Thanks.
Hidding files for all platforms
-
IdeasVacuum
- Always Here

- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: Hidding files for all platforms
... I don't know if Mac actually supports hidden files but if you are, for example, trying to stop Users of a game from cheating, it would be better to encrypt the file as many people have hidden files on their system unhidden by default anyway.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: Hidding files for all platforms
Mac supports hidden files. Putting a period "." in front of the file name will hide the file.IdeasVacuum wrote:... I don't know if Mac actually supports hidden files but if you are, for example, trying to stop Users of a game from cheating, it would be better to encrypt the file as many people have hidden files on their system unhidden by default anyway.
My problem is, I need a crossplatform solution for hidding files. Encryption of this file is not an issue.
Thanks though.
Re: Hidding files for all platforms
Is this not the perfect example of why we have this?
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
; some Windows specific code
CompilerCase #PB_OS_MaxOS
; some Mac specific code
CompilerEndSelect
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
; some Windows specific code
CompilerCase #PB_OS_MaxOS
; some Mac specific code
CompilerEndSelect
Re: Hidding files for all platforms
If #PB_FileSystem_Hidden isn't available on OSX, you can simply check the actual value the constant represents on Windows and use that value directly.
Re: Hidding files for all platforms
Your 2. example works fine on Intel-Mac and MAc OS Snow Leopard (10.6.8 )
.Loc.txt is created as hidden file.
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
OpenFile(3,ProgPath + "Loc.txt")
SetFileAttributes(ProgPath + "Loc.txt",#PB_FileSystem_Hidden)
ReadFile(3, ProgPath + "Loc.txt")
CompilerElse
OpenFile(3,ProgPath + ".Loc.txt")
ReadFile(3, ProgPath + ".Loc.txt")
CompilerEndIfmichel51
Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
Re: Hidding files for all platforms
Thank you all for your help.
I now realize it was the fact I was compiling on a PC and manualy changing the .exe to .app to run on the Mac that was my fatal flaw and was generating the "the Classic Environment is no longer supported" error.
I guess it is not possible to create a Mac .app from a Windows based PureBasic, if this statement is wrong, please let me know.
Thanks.
I now realize it was the fact I was compiling on a PC and manualy changing the .exe to .app to run on the Mac that was my fatal flaw and was generating the "the Classic Environment is no longer supported" error.
I guess it is not possible to create a Mac .app from a Windows based PureBasic, if this statement is wrong, please let me know.
Thanks.
Re: Hidding files for all platforms
Your statement is right.
Windows, OS X and Linux are so different from eachother that you will always need to compile a different version for each OS.
Since PureBasic doesn't do cross compiling (compiling for a different OS you are working on) you will need a Mac to compile for that platform.
Windows, OS X and Linux are so different from eachother that you will always need to compile a different version for each OS.
Since PureBasic doesn't do cross compiling (compiling for a different OS you are working on) you will need a Mac to compile for that platform.
Re: Hidding files for all platforms
wilbert wrote:Your statement is right.
Windows, OS X and Linux are so different from eachother that you will always need to compile a different version for each OS.
Since PureBasic doesn't do cross compiling (compiling for a different OS you are working on) you will need a Mac to compile for that platform.
Thanks for the confirmation wilbert.



