FIle properties

Blitz3D Forums/Blitz3D Beginners Area/FIle properties

Can we adjust file properties through BlitzPlus?
For examples set cetern file readonly or hiden.

Yep, you can do this through the Windows API. See SetFileAttributes on MSDN

For your decls file:
.lib "Kernel32.dll"
GetFileAttributes%(in_filename$):"GetFileAttributesA"
SetFileAttributes%(in_filename$, in_attributes%):"SetFileAttributesA"

SetFileAttributes test code:
; Create a normal test file
file = WriteFile("test.txt")
WriteLine(file, "Testing...")
CloseFile(file)

; See current file attributes
Notify GetFileAttributes("test.txt")

; Change file attributes to hidden and readonly
;SetFileAttributes("test.txt", 3)

; Change file attributes to system only
;SetFileAttributes("test.txt", 4)

; Change file attributes to hidden, system, readonly
;SetFileAttributes("test.txt", 7)

; Change file attribute to hidden, archive
;SetFileAttributes("test.txt", 34)

; Change file attributes back to normal
SetFileAttributes("test.txt", 128)

; See current file attributes
Notify GetFileAttributes("test.txt")



FYI...
FILE_ATTRIBUTE_READONLY = 1
FILE_ATTRIBUTE_HIDDEN = 2
FILE_ATTRIBUTE_SYSTEM = 4
FILE_ATTRIBUTE_DIRECTORY = 16
FILE_ATTRIBUTE_ARCHIVE = 32
FILE_ATTRIBUTE_DEVICE = 64
FILE_ATTRIBUTE_NORMAL = 128

Thanks