|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
Hello,
I wonder if the $folder identifier can be added on the mIRC that will return some useful output results with some props too, like $file identifier.
Props: .size - .mtime - .longfn - .shortfn - .attr
e.g: $folder($mircdir).size output: 1334784
e.g2: $folder($mircdir).mtime output: 1403816309
e.g3: $folder($mircdir).longfn output: C:\Users\Dimitris\Documents\mIRC\
e.g4: $folder($mircdir).shortfn output: C:\Users\Dimitris\DOCUME~1\mIRC\
e.g5: $folder($mircdir).attr output: ar
- Thanks!
|
|
|
|
Joined: Jan 2004
Posts: 1,361
Hoopy frood
|
Hoopy frood
Joined: Jan 2004
Posts: 1,361 |
$file already does all those things for directories except for size
|
|
|
|
Joined: Apr 2010
Posts: 969
Hoopy frood
|
Hoopy frood
Joined: Apr 2010
Posts: 969 |
As loki said $file() can already do everything you've asked except the size property With a little help from COM we can mimic all of $file()'s behavior. The follow alias maps everything but the .size property to $file() If the .size property is specified, it opens a com to the FileSystemObject, retrieves the folder properties, then returns the size property value alias folder {
var %com = folder, %com2 = prop, %err, %res
if ($prop != size) return $file($1-) [ $+ [ $iif($prop,. $+ $prop) ] ]
if ($isdir($1-)) {
.comopen %com Scripting.FileSystemObject
if ($com(%com) && !$comerr) && ($com(%com, GetFolder, 1, bstr, $noqt($1-), dispatch* %com2) && !$comerr) && ($com(%com2, size, 2) && !$comerr) {
%res = $com(%com2).result
}
}
:error
reseterror
if ($com(%com)) { .comclose $v1 }
if ($com(%com2)) { .comclose $v1 }
return %res
} Now, with that out of the way, I think $file() should be extended to handle folder sizes aswell ;edited: Fixed typo in script
Last edited by FroggieDaFrog; 14/08/14 02:16 PM.
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
The code does NOT working, also i didn't knew that the $file working for folders, thanks, but the problem is that $file($mircdir).size (for example) does NOT work, so the suggestion is to make the $file(dir).size to work for folders size.
|
|
|
|
Joined: Apr 2010
Posts: 969
Hoopy frood
|
Hoopy frood
Joined: Apr 2010
Posts: 969 |
There was a typing mistake in the script. It is fixed
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
Thanks for the code, but i am still say to this must be added in $file(FOLDER).size identifier!
- Thanks!
|
|
|
|
Joined: Dec 2002
Posts: 2,962
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,962 |
If by folder size you mean the total size of its contents then just loop through its contents with $findfile() & $file().size and add it up yourself - that's effectively what mIRC would have to do behind the scenes anyway.
It's perhaps best not implemented as a built-in identifier as it can be slow to calculate if the directory contains many (ie. thousands) of files. Generally speaking people assume mIRC's built-in identifiers will return a value near-instantaneously.
Spelling mistakes, grammatical errors, and stupid comments are intentional.
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
alias folder {
if (!$isdir($1-)) { return }
if ($prop == size) {
var %size
noop $findfile($1-,*,0,inc %size $file($1-).size)
return %size
}
return $file($1-) [ $+ [ $iif($prop,. $+ $v1) ] ]
} Edit: don't use that on a big folder :p Took 5 minutes to calculate the size of my Windows directory!
Last edited by hixxy; 14/08/14 09:15 PM.
|
|
|
|
Joined: Apr 2010
Posts: 969
Hoopy frood
|
Hoopy frood
Joined: Apr 2010
Posts: 969 |
Without DLLs or the property being built in, I think my code above is the fastest way to get total size.
I do think the .size prop should be updated to calculate folder size aswell. From my com example above, windows already abstracts the calculations for programmers so extending it should not only be easy, but probably quite a bit more efficient compared to programmatic looping within mIRC
|
|
|
|
Joined: Dec 2008
Posts: 1,515
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,515 |
I agree with FroggieDaFrog , The loop way it was the first one but i think this would not be a good method for large folders the option to add something new in mIRC and useful is the best. so if Khaled add support for $file(FOLDER).size so it could be the best and fastest.
|
|
|
|
|