File: classes.kvs

package info (click to toggle)
kvirc 4%3A5.2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,136 kB
  • sloc: cpp: 232,431; perl: 2,106; pascal: 1,005; sh: 836; ansic: 244; makefile: 58; python: 54; xml: 19
file content (68 lines) | stat: -rw-r--r-- 1,307 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Default classes file

# Compatibility only: do not use.
# Use /addon.installfiles instead.

# 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 $tr("[Installer] Error: the first argument of copyFiles must be a source directory","defscript")
			halt
		}

		if($1 == "")
		{
			echo $tr("[Installer] Error: the second argument of copyFiles must be a file name or file regexp","defscript")
			halt
		}

		if($2 == "")
		{
			echo $tr("[Installer] Error: the third argument of copyFiles must be a destination directory","defscript")
			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";
			}
		}
		else
		{
			%c .= ";$lf";
		}
		%c .= "}"
		eval %c
	}
};