diff options
| author | 2009-07-03 15:19:50 +0000 | |
|---|---|---|
| committer | 2009-07-03 15:19:50 +0000 | |
| commit | d7d77ca777bb8e7b33dc2fbb78fb4fad499fef01 (patch) | |
| tree | ad375f60499d2b3195c2fff00282af97ab40bfde /data/defscript | |
| parent | fixed bug #450 (thanks CtrlAltCa for the help); (diff) | |
| download | KVIrc-d7d77ca777bb8e7b33dc2fbb78fb4fad499fef01.tar.gz KVIrc-d7d77ca777bb8e7b33dc2fbb78fb4fad499fef01.tar.bz2 KVIrc-d7d77ca777bb8e7b33dc2fbb78fb4fad499fef01.zip | |
added classes file in default script: this is useful to create addon
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3303 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'data/defscript')
| -rw-r--r-- | data/defscript/classes.kvs | 61 | ||||
| -rw-r--r-- | data/defscript/default.kvs | 1 |
2 files changed, 62 insertions, 0 deletions
diff --git a/data/defscript/classes.kvs b/data/defscript/classes.kvs new file mode 100644 index 000000000..cfc9eb039 --- /dev/null +++ b/data/defscript/classes.kvs @@ -0,0 +1,61 @@ +# Default classes file + +# A helper class for installing files and generating an uninstallation alias on the fly +class(installer,object) +{ + constructor() + { + $$->%iNumFiles = 0 + } + + copyFiles($0 = source dir, $1 = file regexp, $2 = target dir) + { + if($0 == "") + { + echo "[Installer] Error: the first argument of copyFiles must be a source directory" + halt + } + + if($1 == "") + { + echo "[Installer] Error: the second argument of copyFiles must be a file name or file regexp" + halt + } + + if($2 == "") + { + echo "[Installer] Error: the third argument of copyFiles must be a destination directory" + halt + } + + if($file.exists($0)) + { + %files[] = $file.ls($0,f,$1) + if($length(%files[])) + { + file.mkdir $2 + foreach(%file,%files[]) + { + $$->%lFiles[$$->%iNumFiles] = $str.replace($file.fixpath("$2/%file"),"\\\\","\\") + $$->%iNumFiles++; + file.copy -o "$0/%file" "$2/%file" + } + } + } + } + + generateUninstallAlias($0 = alias name) + { + %c = "alias($0)$lf" + %c .= "{$lf" + if($$->%iNumFiles > 0) + { + foreach(%file,$$->%lFiles[]) + { + %c .= " file.remove \"%file\"$lf"; + } + } + %c .= "}" + eval %c + } +}; diff --git a/data/defscript/default.kvs b/data/defscript/default.kvs index fb270da6d..8968c4084 100644 --- a/data/defscript/default.kvs +++ b/data/defscript/default.kvs @@ -16,6 +16,7 @@ include "aliases.kvs" %mypath include "events.kvs" %mypath include "popups.kvs" %mypath include "toolbars.kvs" %mypath +include "classes.kvs" %mypath # # Set the default spam words...(for the anti-spam) detector |
