Andromo - Start Making Apps - Free Signup

Announcement

Collapse

New Forum Software

If you're here, you've found the new home for our forums. There will be some bugs to iron out, so thanks for your patience...
See more
See less

Function to set ReadOnly to false

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Function to set ReadOnly to false

    This is a function to set the ReadOnly attribute to false on all files in folder and it's subfolder. Useful when you've copied files from a CD to the hard drive.

    Sample Call
    UndoReadOnly("C:\Program Files\My App")


    Global Function
    Code:
    function UndoReadOnly(sFolder)
    	local n;
    	local m_File;
    	
    	--find all files in the passed folder
    	m_tblFiles = File.Find(sFolder, "*.*", true, true, nil)
    	
    	if m_tblFiles ~= nil then
    		--setup the attribute table
    		attrib = {};
    		attrib.ReadOnly = false;
    		--enumerate table
    		for n, m_File in m_tblFiles do
    			--set attribute
    			File.SetAttributes(m_File, attrib);
    		end
    	end
    	
    	--clean up
    	attrib = nil;
    	m_tblFiles = nil;
    end

  • #2
    Thanks Worm. It can be very useful.
    There is also a small *.bat program that does that.
    Problem is that sometimes, you want/need some of the files to be read only and some not (example, backing up a project in Video Editing on some systems).
    I personally always zip the files/folders before burning them on CD. That way their attrib remain.
    If you zip the files/folders, you remain at the original states for all you files.
    Yossi

    Comment


    • #3
      Originally posted by yosik

      Problem is that sometimes, you want/need some of the files to be read only and some not (example, backing up a project in Video Editing on some systems).
      Thats a good idea. You could add another parameter that could be passed to the function as a table where in the table would contain a list of files that you want to remain in the readonly state.

      tROFiles = {"File1.ext", "File2.ext", "File3.ext", "File4.ext"}
      UndoReadOnly("C:\Program Files\My App", tROFiles)
      TJ-Tigger
      "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
      "Draco dormiens nunquam titillandus."
      Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

      Comment


      • #4
        Thx, nice function

        Comment

        Working...
        X