Class: Wiris::FileSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/src-generic/FileSystem.rb

Class Method Summary collapse

Class Method Details

.createDirectory(folder) ⇒ Object



7
8
9
# File 'lib/src-generic/FileSystem.rb', line 7

def self.createDirectory(folder)
	Dir.mkdir(folder)
end

.deleteDirectory(folder) ⇒ Object



28
29
30
31
32
# File 'lib/src-generic/FileSystem.rb', line 28

def self.deleteDirectory(folder)
	if (Dir.entries(folder) == ['.', '..'])
		return Dir.delete(folder)
	end
end

.deleteFile(file) ⇒ Object



33
34
35
# File 'lib/src-generic/FileSystem.rb', line 33

def self.deleteFile(file)
	return File.delete(file)
end

.exists(folder) ⇒ Object



11
12
13
# File 'lib/src-generic/FileSystem.rb', line 11

def self.exists(folder)
	File.exists?(folder)
end

.fullPath(path) ⇒ Object



15
16
17
18
19
20
# File 'lib/src-generic/FileSystem.rb', line 15

def self.fullPath(path)
	if !exists(path)
		return nil
	end
	return File::realpath(path)
end

.isDirectory(path) ⇒ Object



25
26
27
# File 'lib/src-generic/FileSystem.rb', line 25

def self.isDirectory(path)
	return File.directory?(path)
end

.readDirectory(folder) ⇒ Object



3
4
5
# File 'lib/src-generic/FileSystem.rb', line 3

def self.readDirectory(folder)
	return Dir::entries(folder) - ['.'] - ['..']
end

.rename(path, newpath) ⇒ Object

Raises:

  • (Exception)


21
22
23
24
# File 'lib/src-generic/FileSystem.rb', line 21

def self.rename (path, newpath)
	File::rename(path, newpath)
	raise Exception, "Unable to rename \""+path+"\" to \""+newpath+"\"."
end