SetFileMode issue

BlitzMax Forums/BlitzMax Programming/SetFileMode issue

Crovean(Posted 2010) [#1]
I'm having trouble changing files attributes...
Let's say "textdoc.txt" isn't Read-Only... I can easily change it to Read-Only using my code below. But when I try to remove the Read-Only attribute from the file nothing happens.

I want to remove the Read-Only attribute from the file, write data to it, then set the Read-Only attribute to it again. That seems to be impossible tho?

Local writebits=%010000000

Print "BEFORE SetFileMode:"
Print Permissions$(FileMode("testdoc.txt"))
Local mode=FileMode("testdoc.txt")
Print

mode=mode & ~writebits

Print "AFTER SetFileMode:"
SetFileMode("testdoc.txt",mode)	
Print Permissions$(FileMode("testdoc.txt"))

Function Permissions$(m)
	Local	testbit,pos
	Local	p$="rwxrwxrwx"
	testbit=%100000000
	pos=1
	While (testbit)
		If m & testbit res$:+Mid$(p$,pos,1) Else res$:+"-"
		testbit=testbit Shr 1
		pos:+1	
	Wend
	Return res
End Function