Hidding files for all platforms

Mac OSX specific forum
peterowe3
New User
New User
Posts: 4
Joined: Mon Oct 31, 2011 7:13 pm

Hidding files for all platforms

Post by peterowe3 »

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.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Hidding files for all platforms

Post by IdeasVacuum »

... 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.
peterowe3
New User
New User
Posts: 4
Joined: Mon Oct 31, 2011 7:13 pm

Re: Hidding files for all platforms

Post by peterowe3 »

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.
Mac supports hidden files. Putting a period "." in front of the file name will hide the file.

My problem is, I need a crossplatform solution for hidding files. Encryption of this file is not an issue.

Thanks though.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Hidding files for all platforms

Post by Tenaja »

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
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Hidding files for all platforms

Post by wilbert »

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.
User avatar
michel51
Enthusiast
Enthusiast
Posts: 290
Joined: Mon Nov 21, 2005 10:21 pm
Location: Germany

Re: Hidding files for all platforms

Post by michel51 »

Your 2. example works fine on Intel-Mac and MAc OS Snow Leopard (10.6.8 )

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")
CompilerEndIf
.Loc.txt is created as hidden file.
michel51

Mac OS X Snow Leopard (10.6.8 ) Intel
PureBasic V 5.21(x64), V 5.22beta
peterowe3
New User
New User
Posts: 4
Joined: Mon Oct 31, 2011 7:13 pm

Re: Hidding files for all platforms

Post by peterowe3 »

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.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Hidding files for all platforms

Post by wilbert »

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.
peterowe3
New User
New User
Posts: 4
Joined: Mon Oct 31, 2011 7:13 pm

Re: Hidding files for all platforms

Post by peterowe3 »

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.
Post Reply