Page 1 of 1

Hidding files for all platforms

Posted: Tue Nov 08, 2011 1:51 pm
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.

Re: Hidding files for all platforms

Posted: Tue Nov 08, 2011 2:33 pm
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.

Re: Hidding files for all platforms

Posted: Tue Nov 08, 2011 4:47 pm
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.

Re: Hidding files for all platforms

Posted: Tue Nov 08, 2011 5:08 pm
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

Re: Hidding files for all platforms

Posted: Tue Nov 08, 2011 5:22 pm
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.

Re: Hidding files for all platforms

Posted: Tue Nov 08, 2011 6:40 pm
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.

Re: Hidding files for all platforms

Posted: Wed Nov 09, 2011 2:49 pm
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.

Re: Hidding files for all platforms

Posted: Wed Nov 09, 2011 3:17 pm
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.

Re: Hidding files for all platforms

Posted: Wed Nov 09, 2011 8:13 pm
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.