summary refs log tree commit diff stats
path: root/tools
diff options
context:
space:
mode:
authorAndreas Rumpf <andreasrumpf@noname>2009-09-23 23:38:00 +0200
committerAndreas Rumpf <andreasrumpf@noname>2009-09-23 23:38:00 +0200
commit3f3dda5a77fa8faf6d97aa5a0ed3b0fc6e8c0918 (patch)
tree81fcf664ab2abfda200061e57fa488ae17b03192 /tools
parent66a7e3d37c0303997a6b1a3b7ec263dfb8c07748 (diff)
downloadNim-3f3dda5a77fa8faf6d97aa5a0ed3b0fc6e8c0918.tar.gz
implemented multi methods
Diffstat (limited to 'tools')
-rwxr-xr-xtools/inno.tmpl2
-rwxr-xr-xtools/install.tmpl2
-rwxr-xr-xtools/niminst.nim10
-rwxr-xr-xtools/nimweb.nim20
-rwxr-xr-xtools/trimcc.nim7
5 files changed, 21 insertions, 20 deletions
diff --git a/tools/inno.tmpl b/tools/inno.tmpl
index 3cfc04f2d..368846d66 100755
--- a/tools/inno.tmpl
+++ b/tools/inno.tmpl
@@ -20,7 +20,7 @@ Name: english; MessagesFile: compiler:Default.isl
 [Files] 
   #for i in low(TFileCategory)..fcWindows:
   #  for f in items(c.cat[i]):
-Source: ${expandFilename(f)}; DestDir: {app}\${extractDir(f)}; Flags: ignoreversion
+Source: ${expandFilename(f)}; DestDir: {app}\${splitFile(f).dir}; Flags: ignoreversion
   #  end for
   #end for
 
diff --git a/tools/install.tmpl b/tools/install.tmpl
index ffefc8281..acca8a7fb 100755
--- a/tools/install.tmpl
+++ b/tools/install.tmpl
@@ -58,7 +58,7 @@ if [ $# -eq 1 ] ; then
 #var createdDirs = newStringTable()
 #for cat in fcConfig..fcLib:
 #  for f in items(c.cat[cat]):
-#    var mk = extractDir(f.skipRoot)
+#    var mk = splitFile(f.skipRoot).dir
 #    if mk.len > 0:
 #      mk = unixDirVars[cat] & "/" & mk
 #      if not createdDirs.hasKey(mk):
diff --git a/tools/niminst.nim b/tools/niminst.nim
index 13024b68f..b1de0964c 100755
--- a/tools/niminst.nim
+++ b/tools/niminst.nim
@@ -116,7 +116,7 @@ Compile_options:
 """
 
 proc parseCmdLine(c: var TConfigData) =
-  var p = init()
+  var p = initOptParser()
   while true:
     next(p)
     var kind = p.kind
@@ -132,8 +132,8 @@ proc parseCmdLine(c: var TConfigData) =
           of "inno": incl(c.actions, actionInno)
           else: quit(Usage)
       else:
-        c.infile = appendFileExt(key, "ini")
-        c.nimrodArgs = getRestOfCommandLine(p)
+        c.infile = addFileExt(key, "ini")
+        c.nimrodArgs = cmdLineRest(p)
         break
     of cmdLongOption, cmdShortOption:
       case normalize(key)
@@ -255,7 +255,7 @@ proc parseIniFile(c: var TConfigData) =
 proc readCFiles(c: var TConfigData, osA, cpuA: int) =
   var cfg: TCfgParser
   var cfilesSection = false
-  var f = extractDir(c.infile) / "mapping.txt"
+  var f = splitFile(c.infile).dir / "mapping.txt"
   c.cfiles[osA][cpuA] = @[]
   var input = newFileStream(f, fmRead)
   if input != nil:
@@ -302,7 +302,7 @@ proc srcdist(c: var TConfigData) =
                  [c.oses[osA-1], c.cpus[cpuA-1], c.nimrodArgs, 
                  changeFileExt(c.infile, "nim")]
       echo(cmd)
-      if executeShellCommand(cmd) != 0:
+      if execShellCmd(cmd) != 0:
         quit("Error: call to nimrod compiler failed")
       readCFiles(c, osA, cpuA)
       for i in 0 .. c.cfiles[osA][cpuA].len-1:
diff --git a/tools/nimweb.nim b/tools/nimweb.nim
index 5ba5799f9..135ba518a 100755
--- a/tools/nimweb.nim
+++ b/tools/nimweb.nim
@@ -56,7 +56,7 @@ Compile_options:
 """
 
 proc parseCmdLine(c: var TConfigData) =
-  var p = init()
+  var p = initOptParser()
   while true:
     next(p)
     var kind = p.kind
@@ -64,8 +64,8 @@ proc parseCmdLine(c: var TConfigData) =
     var val = p.val
     case kind
     of cmdArgument:
-      c.infile = appendFileExt(key, "ini")
-      c.nimrodArgs = getRestOfCommandLine(p)
+      c.infile = addFileExt(key, "ini")
+      c.nimrodArgs = cmdLineRest(p)
       break
     of cmdLongOption, cmdShortOption:
       case normalize(key)
@@ -84,7 +84,7 @@ proc walkDirRecursively(s: var seq[string], root, ext: string) =
   for k, f in walkDir(root):
     case k
     of pcFile, pcLinkToFile:
-      if cmpIgnoreCase(ext, extractFileExt(f)) == 0:
+      if cmpIgnoreCase(ext, splitFile(f).ext) == 0:
         add(s, f)
     of pcDirectory: walkDirRecursively(s, f, ext)
     of pcLinkToDirectory: nil
@@ -94,7 +94,7 @@ proc addFiles(s: var seq[string], dir, ext: string, patterns: seq[string]) =
     if existsDir(dir / p):
       walkDirRecursively(s, dir / p, ext)
     else:
-      add(s, dir / appendFileExt(p, ext))
+      add(s, dir / addFileExt(p, ext))
 
 proc parseIniFile(c: var TConfigData) =
   var
@@ -143,7 +143,7 @@ proc parseIniFile(c: var TConfigData) =
     if c.projectName.len == 0:
       c.projectName = changeFileExt(extractFilename(c.infile), "")
     if c.outdir.len == 0:
-      c.outdir = extractDir(c.infile)
+      c.outdir = splitFile(c.infile).dir
   else:
     quit("cannot open: " & c.infile)
 
@@ -151,18 +151,18 @@ proc parseIniFile(c: var TConfigData) =
 
 proc Exec(cmd: string) =
   echo(cmd)
-  if os.executeShellCommand(cmd) != 0: quit("external program failed")
+  if os.execShellCmd(cmd) != 0: quit("external program failed")
 
 proc buildDoc(c: var TConfigData, destPath: string) =
   # call nim for the documentation:
   for d in items(c.doc):
     Exec("nimrod rst2html $# -o:$# --index=$#/theindex $#" %
-      [c.nimrodArgs, destPath / changeFileExt(extractFileTrunk(d), "html"),
+      [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"),
        destpath, d])
     Exec("nimrod rst2tex $# $#" % [c.nimrodArgs, d])
   for d in items(c.srcdoc):
     Exec("nimrod doc $# -o:$# --index=$#/theindex $#" %
-      [c.nimrodArgs, destPath / changeFileExt(extractFileTrunk(d), "html"),
+      [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"),
        destpath, d])
   Exec("nimrod rst2html $1 -o:$2/theindex.html $2/theindex" %
        [c.nimrodArgs, destPath])
@@ -171,7 +171,7 @@ proc buildAddDoc(c: var TConfigData, destPath: string) =
   # build additional documentation (without the index):
   for d in items(c.webdoc):
     Exec("nimrod doc $# -o:$# $#" %
-      [c.nimrodArgs, destPath / changeFileExt(extractFileTrunk(d), "html"), d])
+      [c.nimrodArgs, destPath / changeFileExt(splitFile(d).name, "html"), d])
 
 proc main(c: var TConfigData) =
   const
diff --git a/tools/trimcc.nim b/tools/trimcc.nim
index f946256c9..966f406d4 100755
--- a/tools/trimcc.nim
+++ b/tools/trimcc.nim
@@ -2,8 +2,9 @@
 

 import strutils, os

 

-proc newName(f: string): string = 

-  return extractDir(f) / "trim_" & extractFilename(f)

+proc newName(f: string): string =

+  var (dir, name, ext) = splitFile(f)

+  return dir / "trim_" & name & ext

 

 proc walker(dir: string) = 

   for kind, path in walkDir(dir):

@@ -11,7 +12,7 @@ proc walker(dir: string) =
     of pcFile:

       moveFile(newName(path), path)

       # test if installation still works:

-      if executeShellCommand(r"nimrod c --force_build tests\tlastmod") == 0:

+      if execShellCmd(r"nimrod c --force_build tests\tlastmod") == 0:

         echo "Optional: ", path

         removeFile(newName(path))

       else: