Module: Tms

Defined in:
lib/tms.rb,
ext/tms.c

Defined Under Namespace

Modules: Space Classes: Backup

Class Method Summary collapse

Class Method Details

.backup_volumeObject



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
# File 'ext/tms.c', line 4

static VALUE backup_volume(VALUE self){
	OSStatus status = pathTooLongErr;
	char *path;
	size_t pathLength = 256;

	CFDataRef aliasData;
	AliasHandle alias;
	FSRef fs;
	Boolean wasChanged;

	aliasData = CFPreferencesCopyAppValue(CFSTR("BackupAlias"), CFSTR("com.apple.TimeMachine"));
	if (aliasData) {
		if (noErr == PtrToHand(CFDataGetBytePtr(aliasData), (Handle *)&alias, CFDataGetLength(aliasData))) {
			if (noErr == FSResolveAlias(NULL, alias, &fs, &wasChanged)) {
				path = malloc(pathLength);
				while (noErr != (status = FSRefMakePath(&fs, (UInt8*)path, pathLength))) {
					if (pathTooLongErr == status) {
						pathLength += 256;
						path = reallocf(path, pathLength);
					}
				}
			}
			DisposeHandle((Handle)alias);
		}
		CFRelease(aliasData);
	}

	if (noErr == status) {
		return rb_str_new2(path);
	} else {
		return Qnil;
	}
}

.diff(a, b) ⇒ Object



74
75
76
77
78
# File 'lib/tms.rb', line 74

def diff(a, b)
  backup_a = Backup.list[a] || abort("No backup with id #{a}")
  backup_b = Backup.list[b] || abort("No backup with id #{b}")
  Backup.diff(backup_a, backup_b)
end

.listObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/tms.rb', line 59

def list
  backups = Backup.list
  Mutter::Table.new do
    column :align => :right, :style => :red
    column :align => :right, :style => :blue
    column :align => :right
    column
  end.tap do |table|
    table << ['', '', 'num', 'name']
    backups.each_with_index do |backup, i|
      table << [i, i - backups.length, backup.number, backup.name]
    end
  end.print
end