October 28, 2020, 06:25:41 AM

Author Topic: [bmx] File attributes by JoshK [ 1+ years ago ]  (Read 1277 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] File attributes by JoshK [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : File attributes
Author : JoshK
Posted : 1+ years ago

Description : Note that you must call ShowFile() before a hidden file can be read with ReadFile().

Code :
Code: BlitzMax
  1. SuperStrict
  2.  
  3. Import pub.win32
  4.  
  5. Private
  6.  
  7. Const FILE_ATTRIBUTE_HIDDEN:Int=$2
  8.  
  9. Extern "win32"
  10.         Function SetFileAttributesA(lpFileName$z,dwFileAttributes:Int)
  11.         Function GetFileAttributesA:Int(lpFileName$z)
  12. EndExtern
  13.  
  14. Public
  15.  
  16. Function HideFile(path:String)
  17.         Local attrib:Int
  18.         attrib=GetFileAttributesA(path)
  19.         If Not (FILE_ATTRIBUTE_HIDDEN & attrib)
  20.                 SetFileAttributesA(path,attrib|FILE_ATTRIBUTE_HIDDEN)
  21.         EndIf
  22. EndFunction
  23.  
  24. Function ShowFile(path:String)
  25.         Local attrib:Int
  26.         attrib=GetFileAttributesA(path)
  27.         If (FILE_ATTRIBUTE_HIDDEN & attrib)
  28.                 SetFileAttributesA(path,attrib~FILE_ATTRIBUTE_HIDDEN)  
  29.         EndIf
  30. EndFunction
  31.  
  32. Function FileHidden:Int(path:String)
  33.         Local attrib:Int
  34.         attrib=GetFileAttributesA(path)
  35.         If (FILE_ATTRIBUTE_HIDDEN & attrib)
  36.                 Return True
  37.         EndIf
  38. EndFunction


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal