mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2015
Posts: 148
Dazuz Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Dec 2015
Posts: 148
I came across a little problem where $findfile().shortfn/$shortfn return the full path, and /fopen is unable to open because of consecutive spaces.

Code:
//fopen -o file $replacex($qt($mircdira__random___.file),_,$chr(32)) | .fclose file

Is there any workaround for the /fopen command, or can we get some new fancy feature that does the same and works with spaces?



As a side note:
It would be fantastic if you could get all the spaces when you do: $findfile($mircdir,0,1,echo -a $1-)
The $1- truncates the spaces, so you need to go through them all manually to get all the spaces:
$findfile($mircdir,1,1)
$findfile($mircdir,2,1)
$findfile($mircdir,3,1)
...



EDIT:
/bread is another one that could use some kind of a workaround.

Last edited by Dazuz; 14/08/18 01:58 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I do not find consecutive spaces when using $shortfn. It should be flipping either the pathname or filename portions to a short-name when there's a foldername or filename that's not a valid 8.3 name, and doublespaces isn't valid in an 8.3 name.

You can pass consecutive spaces to an $identifier, but not to a /command like /bread because of the way the command line is parsed before handing to them. Fortunately, $parms has a separate context within $findfile() than it has during an event. If you use $findfile() within ON TEXT you can see that it echoes $parms as a different value than within the event itself.

You'll need to validate whether the filename contains doublespaces then alter the filename to be $shortfn($parms) instead of $1-.

Code:
size_alias {
  var %a $1 | if ($regex($1,\x20\x20)) var %a $shortfn($1)
  echo 4 -s %a $sha1(%a,2) / $sha1($1,2)
  bread $qt(%a) 0 $file(%a).size &temp | echo 3 -s binvar size $bvar(&temp,0)
  return %a
}

//noop $findfile($mircdir,*.jpg,0,2,echo 5 -s x $size_alias($parms) )


This shows %a being filled with the $parms passed to it as the $1 parameter. If size_alias had been called as a /command it would not have seen the double spaces. This will show the short-filename if either the foldername or filename contains double spaces.

The red line demonstrates $sha1 gives the same answer regardless whether it sees the double-space-name or the $shortfn.
The green line shows /bread using the $shortfn workaround
The maroon line shows you can get a display of filenames where the items containing doublespaces have been flipped into being short filenames.

Joined: Dec 2015
Posts: 148
Dazuz Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Dec 2015
Posts: 148
Yeah, I kind of randomly encountered those consecutive spaces when I used $findfile().shortfn on a random drive. The files definitely exist, mIRC can definitely see them and I can definitely open them, but mIRC has trouble with shortening them. I can also get the info about the files with $file.

$parms is a life saver though, never even knew it existed, and it completely solved the $findfile problem I had.

After a bit of googling, 8.3 names aren't necessarily always available, so we're left in a position where some files absolutely cannot be opened or read with /fopen or /bread.


EDIT:
Just to clarify: $size_alias fails at opening the file too. It gets the sha1 hashes right, but encounters an error at /bread.

Last edited by Dazuz; 14/08/18 05:19 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Yeah, turns out it can be disabled, as mentioned in the link at
https://forums.mirc.com/ubbthreads.php/topics/252116/Re:_7.41:_$shortfn_problem#Post252116

Since there's no way to pass a double-space to a /command there would need to be a workaround, where a /command expecting a literal filename would need to have a switch informing it that the filename is passed to it in some kind of encoded format, such as a switch indicating the literal filename:

1. actually contains "?" in locations where a consecutive space is present.
2. actually is encoded as base32.

Or have some of these /commands be changed to allow them to be used as identifiers instead of just as a /command.


Link Copied to Clipboard