Re: When Is A Drive Really Read Only?

new topic     » goto parent     » topic index » view thread      » older message » newer message

On mine, it is telling me that '/' write is allowed and my /tmp directory (which is writable) is denied.

I made some thing to complete it a bit:

include std/filesys.e 
include std/console.e 
with trace 
trace(1) 
 
procedure dp(sequence s, sequence args={}) 
    printf(1, s & 10, args) 
end procedure 
 
public function write_to_path(sequence p)  
    integer res = 0  
  
	dp("write access to '" & p & "'")  
	object d = dir(p)  
  
	if sequence(d) then  
		-- dp(sprintf("ATTRIBUTES: %s", { d[1][D_ATTRIBUTES] }))  
		res = find('d', d[1][D_ATTRIBUTES]) and not find('r',d[1][D_ATTRIBUTES])  
	end if  
	if res then  
		dp("...Allowed!",{})  
	else  
		dp("...Denied!",{})  
	end if  
	  
	return res  
end function 
 
sequence dir_name = prompt_string("Enter dir:") 
? write_to_path(dir_name) 
 

One gotcha is that when you test a directory, dir doesn't only give you the information for the passed directory, but all of the children of the directory!

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu