Re: When Is A Drive Really Read Only?
- Posted by SDPringle Oct 04, 2018
- 1144 views
Try this one:
include std/filesys.e include std/console.e 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 if length(d) > 1 then -- it's a directory for i = 1 to length(d) do if equal(d[i][D_NAME],".") then -- forget about the directory's children d[i][D_NAME] = p d = {d[i]} exit end if end for end if dp(sprintf("%s ATTRIBUTES: %s", { d[1][D_NAME], d[1][D_ATTRIBUTES] })) res = find('r', d[1][D_ATTRIBUTES]) = 0 end if if res then dp("...Allowed!",{}) else dp("...Denied!",{}) end if return res end function sequence dir_name = prompt_string("Enter file or directory:") write_to_path(dir_name)