mIRC Home    About    Download    Register    News    Help

Print Thread
#203748 26/08/08 01:38 AM
Joined: Oct 2003
Posts: 110
D
Vogon poet
OP Offline
Vogon poet
D
Joined: Oct 2003
Posts: 110
Hello all,

Has anyone managed to write a dll or weird call to get file size on those unicode paths outside of the current locale that mirc cant handle?
(ie $exists(%unicodefilepath) returns false on a perfectly valid path, but with characters outside of the current locale(typically a russian or japanese filename in an english-default-locale-for-non-unicode-programs windows))

Thanks for any help,

dw

Last edited by DeathWolf; 26/08/08 01:40 AM.
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Try this:
Code:
alias isfilew {
  var %a = isfilew $+ $ticks, %b
  .comopen %a Scripting.FileSystemObject
  if ($comerr) return
  if ($com(%a,FileExists,1,bstr,$1)) %b = $com(%a).result
  .comclose %a
  return %b
}


Edit:
here's a more flexible solution. Usage is $existsw(path,N)
If N = 1, it checks for files (same as $isfile)
If N = 2, it checks for directories (same as $isdir)
Otherwise it checks for either (same as $exists)

Code:
alias existsw {
  var %a = isfilew $+ $ticks, %b
  .comopen %a Scripting.FileSystemObject
  if ($comerr) return
  if $2 !isnum 1-2 {
    if ($com(%a,FileExists,1,bstr,$1)) %b = $com(%a).result
    if (!%b && ($com(%a,FolderExists,1,bstr,$1))) %b = $com(%a).result
  }
  elseif $2 == 1 {
    if ($com(%a,FileExists,1,bstr,$1)) %b = $com(%a).result
  }
  elseif ($com(%a,FolderExists,1,bstr,$1)) %b = $com(%a).result
  .comclose %a
  return %b
}

Last edited by qwerty; 26/08/08 02:18 AM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Oct 2003
Posts: 110
D
Vogon poet
OP Offline
Vogon poet
D
Joined: Oct 2003
Posts: 110
Thanks! that worked great.
How would multiple call work?
(ie GetFile and then the property size to get the filesize?)

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Code:
alias fsize {
  var %a = fsize $+ $ticks, %b = %a $+ file, %c
  .comopen %a Scripting.FileSystemObject
  if ($comerr) return
  noop $com(%a,GetFile,1,bstr,$1,dispatch* %b)
  if $com(%b) {
    if ($com(%b,Size,2)) %c = $com(%b).result
    .comclose %b
  }
  .comclose %a
  return %c
}

The above can be used without checking if the file exists first with $isfilew: if it doesn't, $fsize returns $null.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Oct 2003
Posts: 110
D
Vogon poet
OP Offline
Vogon poet
D
Joined: Oct 2003
Posts: 110
thanks a lot again.
mIRC COM calls are starting to make sense here. I think I'll be able to use them now:)


Link Copied to Clipboard