Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2007
    Posts
    2

    Lightbulb Hidden files attribute Error

    Code:
    -- read attribute from dummy file
    attrib = File.GetAttributes(_SourceDrive.."\\pagefile.txt");
    
    -- read and create ISO format of AccessDate
    strAccessDate = attrib.AccessDateISO;
    
    -- display AccessDate in format  2007-09-14T11:34:54
    Dialog.Message("", strAccessDate);
    This work fine, but if I change pagefile.txt to pagefile.sys which is hidden and system file
    I get error mesage:
    Code:
    Error
    On Next, Line 9: attempt to index global `attrib'(a nil vaule)
    For some reason it cant read attributes from hidden files!
    Any Hint?

  2. #2
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,862
    This is a "known" issue.

    I use FSO to get around this -- here's my "fso" file -- it has some functions that are "swapable" with the stock ones (takes the same paraeters, and returns the same data) It needs my BitWise Plugin

    Code:
    -- SUF's LUA objects (file.) don't handle hidden/system files very well
    -- this wraps those items with fso objects.
    
    function FSOFileThere( cFile ) 
    	local bFileThere = false;
    	--dbgout("Testing for file",cFile);
    	if not Empty( cFile ) then
    		local oFSO = luacom.CreateObject("scripting.filesystemobject");
    		if oFSO then
    			local cDrive = JustDrive( cFile );
    			if not Empty(cDrive) then
    				--dbgout("Getting status for drive",cDrive);
    				local oDrv = oFSO:GetDrive( cDrive ) ;
    				if oDrv then
    					if oDrv.IsReady then
    						bFileThere = oFSO:FileExists(cFile) ;
    					end
    				else
    					bFileThere = File.DoesExist( cFile );
    				end		
    			end
    			oDrv = nil;
    			oFSO = nil;
    			collectgarbage();
    		else
    			bFileThere = File.DoesExist( cFile );
    		end
    	end -- empty()
    	return bFileThere;
    end
    
    function FSOFileVersion( cFile ) 
    	local cVersion = "";
    	if File.IsThere(cFile) then
    		local oFSO = luacom.CreateObject("scripting.filesystemobject");
    		if oFSO then
    			cVersion = oFSO:GetFileVersion(cFile) ;
    			oFSO = nil;
    			collectgarbage();
    		else
    			cVersion = File.VersionInfo( cFile );
    		end
    	end
    	return cVersion;
    end
    
    function FSOFileSize( cFile ) 
    	local nSize = -1;
    	if File.IsThere( cFile ) then
    		local oFSO = luacom.CreateObject("scripting.filesystemobject");
    		if oFSO then
    			local oFile = oFSO:GetFile(cFile) ;
    			assert(oFile,"File Object failed");
    			nSize = oFile.Size;
    			oFile = nil;
    			oFSO = nil;
    			collectgarbage();
    		else
    			nSize = File.Size( cFile );
    		end
    	end
    	return nSize;
    end
    
    function FileCRC( cFile ) 
    end
    
    function FSOFileInfo( cFile )
    	local tInfo = nil;
    	if File.IsThere( cFile ) then
    		local oFSO = luacom.CreateObject("scripting.filesystemobject");
    		if oFSO then
    			tInfo = {}; --WriteDateISO="", CreationDateISO="", AccessDateISO="",Type="",Normal=false,ReadOnly=false,System=false,Archive=false,Hidden=false,Temporary=false,Compressed=false};
    			local oFile = oFSO:GetFile( cFile );
    			assert(oFile,"File Object failed");
    			tInfo.WriteDateISO 		= ISODate(oFile.DateLastModified);
    			tInfo.CreationDateISO = ISODate(oFile.DateCreated);
    			tInfo.AccessDateISO 	= ISODate(oFile.DateLastAccessed);
    			local nAttr 					= oFile.Attributes;
    			if nAttr == 0 then
    				tInfo.Normal = true;
    			else
    				tInfo.ReadOnly 	=	BitWise.BitAnd( nAttr, 1 		)>0;
    				tInfo.Hidden		= BitWise.BitAnd( nAttr, 2 		)>0;
    				tInfo.System 		=	BitWise.BitAnd( nAttr, 4 		)>0;
    				tInfo.Archived	= BitWise.BitAnd( nAttr, 32		)>0;
    				tInfo.Compressed=	BitWise.BitAnd( nAttr, 2048	)>0;
    			end
    			tInfo.Type = oFile.Type;
    			oFile=nil;
    			oFSO=nil;
    			collectgarbage();		
    		else
    			tInfo = File.GetAttributes( cFile );
    			tInfo.WriteDateISO 		= String.Transform(tInfo.WriteDateISO,"T"," ");
    			tInfo.CreationDateISO = String.Transform(tInfo.CreationDateISO,"T"," ");
    			tInfo.AccessDateISO 	= String.Transform(tInfo.AccessDateISO,"T"," ");
    		end
    	end
    	return tInfo;
    end
    
    function ISODate( cDate )
    	local cReturn = "";
    	-- Convert: 8/6/2000 1:50:20 AM 	MM/DD/YYYY HH:MM:SS A/PM
    	-- into:    2000-08-06 01:50:20		YYYY-MM-DD HH:MM:SS
    	if type(cDate) == "string" then
    		local cMonth = PadL(String.Left( cDate, String.Find( cDate, '/')-1), 2, '0');
    		cDate = String.Mid( cDate, String.Find( cDate, '/')+1, String.Length( cDate ) );
    		local cDay   = PadL( String.Left( cDate, String.Find( cDate, '/')-1), 2, '0');
    		cDate = String.Mid( cDate, String.Find( cDate, '/')+1, String.Length( cDate ) );
    		local cYear = String.Left( cDate, 4 );
    		cDate = String.Mid( cDate, 6, String.Length( cDate ) ); 
    		
    		-- Now cDate holds only the time.
    		local nHour = String.ToNumber( String.Left( cDate, String.Find(cDate,":")-1));
    		if String.Right(cDate, 2)=="PM" then
    		  nHour = nHour + 12;
    		end
    		cDate = String.Left(cDate, String.Length(cDate)-3); -- get rid of AM/PM
    		cDate = String.Mid( cDate, String.Find(cDate,":"), String.Length(cDate) );
    		
    		cReturn = cYear..'-'..cMonth..'-'..cDay..' '..PadL(nHour,2,'0')..cDate;
    	end
    	return cReturn;
    end
    
    
    -- Extend File object
    File.IsThere = FSOFileThere;
    File.Version = FSOFileVersion;
    File.Size 	= FSOFileSize;
    File.Info 	= FSOFileInfo;
    Last edited by jassing; 09-14-2007 at 09:24 AM.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  3. #3
    Join Date
    Sep 2007
    Posts
    2
    wow, I will need time to analise this
    Thanks

  4. #4
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,862
    Quote Originally Posted by mikzik View Post
    wow, I will need time to analise this
    Thanks
    Get the bitwise plugin & put that code into a lua file and add it into your project.
    then use File.Info() just like you'd use File.GetAttributes()


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

Similar Threads

  1. Can't figure this error out:
    By aquafina2 in forum Setup Factory 7.0
    Replies: 0
    Last Post: 04-20-2006, 03:53 PM
  2. Unable to find software?
    By NigelLacey in forum Visual Patch 2.0
    Replies: 4
    Last Post: 10-11-2005, 10:35 AM
  3. Veirfy Files Error
    By centsoft in forum Setup Factory 6.0
    Replies: 1
    Last Post: 09-10-2003, 08:31 AM
  4. Error in adding files to CD-ROM Tab!!!
    By Patrik in forum Setup Factory 6.0
    Replies: 2
    Last Post: 02-06-2002, 09:49 AM
  5. SUF6.0.0.2 -- installer hangs.
    By jassing in forum Setup Factory 6.0
    Replies: 4
    Last Post: 12-19-2001, 11:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts