15
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
* used to access the Contracts File object and read its content
18
21
public class Contractor.ContractFile : Object {
23
* contract files filename extension
19
25
private const string EXTENSION = ".contract";
28
* the File object used to access its content
33
* the constructor to create ContractFile object which contains the passed
36
* @param file the file to contain
23
38
public ContractFile (File file) {
43
* get the contract ID from the filename, e.g. file-roller-compress
44
* (file-roller-compress.contract)
46
* @return the contracts ID, e.g. file-roller-compress
27
48
public string get_id () {
28
49
return remove_extension (file.get_basename ());
53
* loads and returns the internally stored files content
55
* @return the files content as string
31
57
public string get_contents () throws Error {
34
if (file.load_contents (null, out file_data, null))
60
if (file.load_contents (null, out file_data, null)) {
35
61
return (string) file_data;
68
* checks if the filename extension is '.contract'
70
* @param filename the full filename incl. the filename extension
72
* @return true if the filename extension is '.contract'; false otherwise
40
74
public static bool is_valid_filename (string filename) {
41
75
return filename[- EXTENSION.length : filename.length] == EXTENSION;
79
* removes the filename extension and returns the result
81
* @param file_name the filename incl. the filename extesnion
83
* @return the filename without the filename extension
44
85
private static string remove_extension (string file_name) {
45
86
return file_name[0 : - EXTENSION.length];