19
19
public string pass = "0";
20
20
public string line = "";
22
public string device_uuid {
24
if (device.down().has_prefix("uuid=")){
25
return device.replace("\"","").replace("'","").split("=")[1];
32
device = "UUID=%s".printf(value);
22
36
public static Gee.ArrayList<FsTabEntry> read_file(string file_path){
23
37
var list = new Gee.ArrayList<FsTabEntry>();
76
public static string create_file_text(
77
FsTabEntry[] entries, bool keep_comments_and_empty_lines = true){
90
public static string write_file(
91
Gee.ArrayList<FsTabEntry> entries, string file_path,
92
bool keep_comments_and_empty_lines = false){
96
if (!keep_comments_and_empty_lines){
97
text += "# <file system> <mount point> <type> <options> <dump> <pass>\n\n";
80
100
foreach(var entry in entries){
81
101
if (entry.is_comment || entry.is_empty_line){
82
102
if (keep_comments_and_empty_lines){
89
109
entry.options, entry.dump, entry.pass);
113
// sort the entries based on mount path
114
// this is required to ensure that base paths are mounted before child paths
116
entries.sort((a, b)=>{
117
return strcmp(a.mount_point, b.mount_point);
120
if (file_exists(file_path)){
121
file_delete(file_path);
124
file_write(file_path, text);
95
public string get_uuid(){
96
if (device.down().has_prefix("uuid=")){
97
return device.replace("\"","").replace("'","").split("=")[1];
129
public string subvolume_name(){
130
if (options.contains("subvol=")){
131
return options.split("subvol=")[1].split(",")[0].strip();
138
public bool is_for_system_directory(){
140
if (mount_point.has_prefix("/mnt")
141
|| mount_point.has_prefix("/mount")
142
|| mount_point.has_prefix("/sdcard")
143
|| mount_point.has_prefix("/cdrom")
144
|| mount_point.has_prefix("/media")
145
|| (mount_point == "none")
146
|| !mount_point.has_prefix("/")
147
|| (!device.has_prefix("/dev/") && !device.down().has_prefix("uuid="))){
156
public static FsTabEntry? find_entry_by_mount_point(
157
Gee.ArrayList<FsTabEntry> entries, string mount_path){
159
foreach(var entry in entries){
160
if (entry.mount_point == mount_path){
167
public void append_option(string option){
169
if (!options.contains(option)){
170
options += ",%s".printf(option);
173
if(options.has_prefix(",")){
174
options = options[1:options.length];
177
options = options.strip();
180
public void remove_option(string option){
182
options = options.replace(option,"").strip();
184
if(options.has_prefix(",")){
185
options = options[1:options.length];
188
if (options.has_suffix(",")){
189
options = options[0:options.length - 1];
192
options = options.strip();