1. question on func get_file_info

Is there a better/simplier/faster solution for this?

include file.e

function get_file_info(sequence x)
	object dx
	dx=dir(x)
	if length(dx)=1 then
		return dx[1]
	end if
	return 0
end function


Does anybody use similar routine(s) regularly? 
Is it worth to propose it for a standard include file?

Thanks,

Salix

new topic     » topic index » view message » categorize

2. Re: question on func get_file_info

Salix wrote:
> 
> Is there a better/simplier/faster solution for this?
> 
> }}}
<eucode>
> include file.e
> 
> function get_file_info(sequence x)
> 	object dx
> 	dx=dir(x)
> 	if length(dx)=1 then --<-- possible error; need test

You'll get an error here if directory x doesn't exist because x will be a
atom and you can't get the length of an atom.

> 		return dx[1]
> 	end if
> 	return 0
> end function
> </eucode>
{{{

new topic     » goto parent     » topic index » view message » categorize

3. Re: question on func get_file_info

c.k.lester wrote:
> > 	if length(dx)=1 then --<-- possible error; need test

You are right. 

Is there any other way to collect this information? 
I mean without calling file.e and dir()?

Regards,

Salix

new topic     » goto parent     » topic index » view message » categorize

4. Re: question on func get_file_info

Salix wrote:
> 
> Is there a better/simplier/faster solution for this?
> 
> }}}
<eucode>
> include file.e
> 
> function get_file_info(sequence x)
> 	object dx
> 	dx=dir(x)
> 	if length(dx)=1 then
> 		return dx[1]
> 	end if
> 	return 0
> end function
> </eucode>
{{{

> 
> Does anybody use similar routine(s) regularly? 
> Is it worth to propose it for a standard include file?
> 
> Thanks,
> 
> Salix


Hello Salix,

  
I   use similar routines with dates. What I would do is create a new include
file called my_file.e. Put in get_dir_name(object dir),get_dir_size(object
dir)and get_dir_attributes(object dir) etc... Put in an error trap that says
"Directry not found". No I don't think this should go into a standard routine.



Don Cole

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu