ircN for mIRC — File Browser

ircNformIRCv6.0 / ircNformIRCv6.0 / ircn / SYSTEM / Idos.mrc

Idos.mrc — 12.57 KB — Download this file

;%%%%%%%%%%%%%%%%%%%%%%%%
;script iDOS
;version 1.01
;author icN
;email icn@ircn.com
;url http://www.ircN.com
;%%%%%%%%%%%%%%%%%%%%%%%%
on 1:LOAD {
  if (%dir.path) {
    window -ade @iDOS %idloc @iDOS Terminal
    if (%idoswarn) {
      aex iDOS is a utility made to simulate a Windows DOS shell prompt.  Because of mIRC limitations, listing large directories (i.e c:\windows\ or c:\program files\) may cause your mIRC to freeze, however listing small directories should cause no problems.  If you do freeze, go to the task manager, close mIRC, and remember not to list that directory ever again!
      aexw
      unset %idoswarn
    }
    aex iDOS(r) for %ver
    if ($findfile(%dir.path,*.*,1) == $null) {
      aexw
      aexw No files were found in this directory.
      aexw Path may be invalid. ( $+ %dir.path $+ )
    }
    aexw
    aex %dir.path $+ >
  }
}
on 1:INPUT {
  if ((@iDOS == $active) && ($left($1,1) != /)) {
    rline @iDOS $line(@iDOS,0) %dir.path $+ > $+ $1-
    if ($left($1,2) == cd) {
      if ($3) {
        aexw
        aexw Too many parameters - $3
        nwdir
      }
      elseif ($2 == /?) {
        aexw
        aexw Displays the name of or changes the current directory.
        aexw
        aexw CD [drive:][path]
        aexw CD[..]
        aexw
        aexw  ..   Specifies that you want to change to the parent directory.
        aexw
        aexw Type CD drive: to display the current directory in the specified drive.
        aexw Type CD without parameters to display the current drive and directory.
        nwdir
      }
      elseif (($1 == cd) && ($2 == $null)) {
        aexw
        aex %dir.path
        nwdir
      }
      elseif (($1 == cd.) && ($2 == $null)) nwdir
      elseif ($left($1,3) == cd\) {
        if ($1 == cd\) {
          if ($mid(%dir.path,2,1) == $chr(58)) set %dir.path $left(%dir.path,1) $+ :\
          elseif ($left(%dir.path,1) == \) set %dir.path \
          else set %dir.path $left($mircdir,3)
          warndir
          nwdir
        }
        else {
          if ($left(%dir.path,1) == $chr(92)) set %dir.path \ $+ $mid($1,4,256)
          else set %dir.path $left(%dir.path,3) $+ $mid($1,4,256)
          if ($right(%dir.path,1) == $chr(92)) set %dir.path $getleft(%dir.path)
          nwdir
        }
      }
      elseif (($1 == cd..) || ($2 == ..)) {
        if ((%dir.path == \) || ($right(%dir.path,2) == :\)) {
          aexw
          aexw Invalid directory
          aexw
          aex %dir.path $+ >
        }
        elseif ($count(%dir.path,\) == 1) {
          if ($chr(58) isin %dir.path) set %dir.path $left(%dir.path,3)
          else set %dir.path \
          warndir
          nwdir
        }
        else {
          set %dir.path $getleft($left(%dir.path,$sub($len(%dir.path),$len($token($pls(1,$count(%dir.path,\)),92,%dir.path)))))
          nwdir
        }
      }
      elseif ($2) {
        if ($2 == \) {
          if ($mid(%dir.path,2,1) == $chr(58)) set %dir.path $left(%dir.path,1) $+ :\
          elseif ($left(%dir.path,1) == \) set %dir.path \
          else set %dir.path $left($mircdir,3)
          warndir
          nwdir
        }
        else chdir $2-
      }
      halt
    }
    elseif (($1 == dir) || ($1 == ls)) {
      if ($2 == /?) {
        aexw
        aexw Displays a list of files and subdirectories in a directory.
        aexw
        aexw        DIR [drive:][path][filename] [list first N files]
        nwdir
      }
      else lsdir $2
      halt
    }
    elseif ($1 == exit) {
      iexit
      halt
    }
    elseif (($1 == del) || ($1 == erase)) {
      if ($3) {
        aexw
        aexw Too many parameters - $3
        nwdir
      }
      elseif ($2 == /?) {
        aexw
        aexw Deletes one or more files.
        aexw
        aexw DEL [drive:][path]filename [/P]
        aexw ERASE [drive:][path]filename [/P]
        aexw
        aexw   [drive:][path]filename $str(每,2) Specifies the file(s) to delete.  Specify
        aexw $str(每,25) multiple files by using wildcards.
        aexw
        nwdir
      }
      else idel $2
      halt
    }
    elseif ($1 == type) {
      if ($2) {
        if ($2 == /?) {
          aexw
          aexw Displays the contents of text files.
          aexw
          aexw TYPE [drive:][path]filename
          nwdir
        }
        else {
          set %dir.rtmp %dir.path $+ \ $+ $2
          if ($exists(%dir.rtmp)) itype %dir.rtmp
          else {
            aexw
            aexw File not found - $2
            nwdir
          }
        }
      }
      else {
        aexw
        aexw Required parameter missing
        nwdir
      }
      halt
    }
    elseif ($left($1,5) == chdir) {
      aexw
      aexw Displays the name of or changes the current directory.
      aexw
      aexw CD [drive:][path]
      aexw CD[..]
      aexw
      aexw  ..   Specifies that you want to change to the parent directory.
      aexw
      aexw Type CD drive: to display the current directory in the specified drive.
      aexw Type CD without parameters to display the current drive and directory.
      nwdir
      halt
    }
    elseif (($mid($1,2,1) == $chr(58)) && ($len($1) < 4)) {
      chdrive $1-
      halt
    }
    else {
      set %dir.rtmp %dir.path $+ \ $+ $1
      set %dir.rtmp2 %dir.path $+ \ $+ $1 $+ .exe
      set %dir.rtmp3 %dir.path $+ \ $+ $1 $+ .com
      set %dir.rtmp4 %dir.path $+ \ $+ $1 $+ .bat
      set %dir.rtmp5 $findfile(%dir.path,$1*,1)
      if ($exists(%dir.rtmp)) run %dir.rtmp
      elseif ($exists(%dir.rtmp2)) run %dir.rtmp2
      elseif ($exists(%dir.rtmp3)) run %dir.rtmp3
      elseif ($exists(%dir.rtmp4)) run %dir.rtmp4
      elseif (%dir.rtmp5) run %dir.rtmp5
      else {
        aexw
        aexw Bad command or file name
      }
      nwdir
      halt
    }
  }
}
alias aex echo @iDOS $1-
alias aexw echo @iDOS $chr(255) $1-
alias nwdir {
  aexw
  ckdir
  aex %dir.path $+ >
}
alias chdir {
  if ($mid($1,2,2) == :\) {
    set %dir.path $1
    if (($right(%dir.path,1) == \) && ($len(%dir.path) > 4)) set %dir.path $getleft(%dir.path)
  }
  elseif ($left($1,1) == \) {
    if ($left(%dir.path,1) == \) set %dir.path $1
    else set %dir.path $left(%dir.path,1) $+ : $+ $1
    if ($right(%dir.path,1) == \) set %dir.path $getleft(%dir.path)
  }
  elseif ($len(%dir.path) <= 3) {
    set %dir.path %dir.path $+ $1
  }
  else {
    set %dir.path %dir.path $+ \ $+ $1
    if ($right(%dir.path,1) == \) set %dir.path $getleft(%dir.path)
  }
  nwdir
}
alias chdrive {
  if ($left($1,1) isnum) {
    aexw
    aexw Invalid drive specification
    nwdir
  }
  elseif ($len($1) == 2) {
    set %dir.path $1 $+ \
    warndir
    nwdir
  }
  elseif (($len($1) == 3) && ($right($1,1) == $chr(92))) {
    set %dir.path $1
    warndir
    nwdir
  }
  else {
    aexw
    aexw Bad command or file name
    nwdir
  }
}
alias ckdir {
  if ($findfile(%dir.path,*.*,1) == $null) {
    aexw No files were found in this directory.
    aexw Path may be invalid. ( $+ %dir.path $+ )
    aexw
  }
}
alias lsdir {
  set %dir.num 0
  set %dir.bytes 0
  unset %dir.dir
  if ($2) {
    set %dir.list $1
    if ($2 isnum) set %dir.max $2
    else unset %dir.max
  }
  elseif ($1) {
    set %dir.list $1
    unset %dir.max
  }
  else {
    set %dir.list *.*
    unset %dir.max
  }
  aexw
  aexw Directory of %dir.path ( $+ %dir.list $+ )
  aexw
  if ($right(%dir.path,2) == :\) set %dir.path $left(%dir.path,2)
  set %i 0
  :start
  inc %i
  set %dir.tmp $findfile(%dir.path,%dir.list,%i)
  if ((%dir.tmp == $null) || (%dir.num == %dir.max)) {
    if ((%dir.num == 0) && (%dir.dir == $null)) && ((%dir.list == *.*) || (%dir.list == *)) {
      aexw
      aexw $ifix(8,.) $ilfix(11,<DIR>)
      aexw $ifix(8,..) $ilfix(11,<DIR>)
      aexw $ilfix(10,0) file(s) $ilfix(13,0) bytes
      aexw
    }
    elseif ((%dir.num == 0) && (%dir.dir == $null)) {
      aexw File not found
      aexw
    }
    else {
      aex $ilfix(12,%dir.num) file(s) $ilfix(13,$inscma(%dir.bytes)) bytes
      aexw
    }
    if (($len(%dir.path) == 2) && ($right(%dir.path,1) == :)) set %dir.path %dir.path $+ \
    aex %dir.path $+ >
  }
  elseif (($count(%dir.tmp,\) == $pls(2,$count(%dir.path,\))) && (%dir.dir != $token($count(%dir.tmp,$chr(92)),92,$nofile(%dir.tmp)))) {
    set %dir.dir $token($count(%dir.tmp,$chr(92)),92,$nofile(%dir.tmp))
    if (($len(%dir.dir) > 8) || ($chr(46) isin %dir.dir) || ($chr(32) isin %dir.dir)) {
      if ($chr(46) isin %dir.dir) {
        if ($count(%dir.dir,$chr(46)) == 1) {
          set %dir.ext $ifix(3,$token(2,46,%dir.dir))
          if ($len($token(1,46,%dir.dir)) > 8) set %dir.beg $ifix(6,$left($token(1,46,%dir.dir),6)) $+ ~1
          else set %dir.beg $ifix(8,$token(1,46,%dir.dir))
        }
        else {
          set %dir.ext $ifix(3,$token($pls(1,$count(%dir.dir,$chr(46))),46,%dir.dir))
          set %dir.beg $left($remove($left(%dir.dir,$sub($len(%dir.dir),$len(%dir.ext))),$chr(46)),6) $+ ~1
          set %dir.beg $ifix(8,%dir.beg)
        }
      }
      else {
        set %dir.ext $str(每,3)
        set %dir.beg $ifix(6,$left($remove(%dir.dir,$chr(32)),6)) $+ ~1
      }
    }
    else {
      set %dir.ext $str(每,3)
      set %dir.beg $ifix(8,%dir.dir)
    }
    aexw %dir.beg %dir.ext $str(每,2) $ifix(16,<DIR>) %dir.dir
    goto start
  }
  else {
    set %dir.nopath $remove($nopath(%dir.tmp),$chr(32))
    if ($count(%dir.tmp,\) == $pls(1,$count(%dir.path,\))) {
      if ($count(%dir.nopath,$chr(46)) == 0) {
        if (($len(%dir.nopath) > 8) || ($chr(32) isin $nopath(%dir.tmp))) set %dir.temp $left(%dir.nopath,6) $+ ~1
        else set %dir.temp %dir.nopath
        set %dir.temp $ifix(8,%dir.temp)
        set %dir.temp %dir.temp $str(每,3)
      }
      elseif ($count(%dir.nopath,$chr(46)) > 1) {
        set %dir.temp $remove($left(%dir.nopath,$sub($len(%dir.nopath),$len($token($pls(1,$count(%dir.nopath,$chr(46))),46,%dir.nopath)))),$chr(46))
        set %dir.temp $left(%dir.temp,6) $+ ~1
        set %dir.temp $ifix(8,%dir.temp) $ifix(3,$left($token($pls(1,$count(%dir.nopath,$chr(46))),46,%dir.nopath),3))
      }
      else {
        set %dir.temp $token(1,46,%dir.nopath)
        if (($len(%dir.temp) > 8) || ($chr(32) isin $nopath(%dir.tmp))) set %dir.temp $left(%dir.temp,6) $+ ~1
        else set %dir.temp $ifix(8,%dir.temp)
        set %dir.temp %dir.temp $ifix(3,$left($token($pls(1,$count(%dir.nopath,$chr(46))),46,%dir.nopath),3))
      }
      aexw %dir.temp $ilfix(13,$inscma($lof(%dir.tmp))) $str(每,5) $nopath(%dir.tmp)
      inc %dir.num
      inc %dir.bytes $lof(%dir.tmp)
    }
    goto start
  }
}
alias idel {
  if ($chr(42) isin $1) {
    if ($right(%dir.path,2) == :\) set %dir.path $left(%dir.path,2)
    set %i 0
    :start
    inc %i
    set %dir.tmp $findfile(%dir.path,$1,%i)
    if (%dir.tmp == $null) {
      if (%dir.repeat == $null) {
        set %i 0
        set %dir.repeat loop
        goto start
      }
      if (%i == 1) {
        aexw
        aexw File not found
      }
      if (($len(%dir.path) == 2) && ($right(%dir.path,1) == :)) set %dir.path %dir.path $+ \
      unset %dir.repeat
      aexw
      aex %dir.path $+ >
    }
    else {
      if ($count(%dir.tmp,\) == $pls(1,$count(%dir.path,\))) .remove %dir.tmp
      goto start
    }
  }
  else {
    set %dir.rtmp %dir.path $+ \ $+ $1
    if ($exists(%dir.rtmp)) .remove %dir.rtmp
    else {
      aexw
      aexw File not found
    }
    aexw
    aex %dir.path $+ >
  }
}
alias itype {
  aexw
  set %i 0
  :start
  inc %i
  if (%i <= $lines(%dir.rtmp)) {
    aexw $read -nl $+ %i %dir.rtmp
    goto start
  }
  nwdir
}
alias warndir {
  aexw
  aexw Listing from root directories may cause your mIRC to freeze.
  aexw If this drive has a lot of files, please leave this directory.
}
alias ifix %tmp1 = $1 - $len($2-) | return $2- $+ $str($chr(255),%tmp1)
alias ilfix %tmp1 = $1 - $len($2-) | return $str($chr(255),%tmp1) $+ $2-
alias iexit {
  set %idloc $swlc(@iDOS)
  window -c @iDOS
  unset %dir.*
  .timer 1 1 .unload -rs idos.mrc

}
menu @iDOS {
  dclick { iexit | halt }
  dir { lsdir | halt }
  cd { chdir $$?="Enter directory (full path required)" | halt }
  del { idel $$?="Enter filename (or wildcard)" | halt }
  run { run $$dir="Select a file" [ %dir.path $+ \ $+ [ %dir.list ] ] | halt }
  type {
    if (%dir.list) itype $$dir="Select a file" [ %dir.path $+ \ $+ [ %dir.list ] ]
    else itype $$dir="Select a file" [ %dir.path $+ \*.* ]
    halt
  }
  -
  exit { iexit | halt }
}