~ximion/listaller/master

« back to all changes in this revision

Viewing changes to src/ipk-filelist.vala

  • Committer: Matthias Klumpp
  • Date: 2014-09-07 02:32:09 UTC
  • Revision ID: git-v1:e6ba4d4678f83926e628759d784655913f65997a
Various fixes to smaller quirks when building IPK packages

* More checks for the input AppData
* Do not recursively find stuff with wildcards
* Allow files without timestamp in release

Show diffs side-by-side

added added

removed removed

Lines of Context:
276
276
                return list;
277
277
        }
278
278
 
 
279
        private void refine_fileentry_add_to_list (ArrayList<FileEntry> resList, FileEntry fe, string root_dir, string fname) {
 
280
                FileEntry e = new FileEntry ();
 
281
 
 
282
                // Create secure filenames, so Listaller doesn't try to rename files with spaces in their name
 
283
                var fs = fname;
 
284
                if (fs.index_of (" ") > 0)
 
285
                        fs = "'%s'".printf (fs);
 
286
 
 
287
                e.fname = fs;
 
288
                e.destination = Path.build_filename (fe.destination, Path.get_dirname (fname).replace (root_dir, ""), null);
 
289
                resList.add (e);
 
290
        }
 
291
 
279
292
        public ArrayList<FileEntry> get_files_list_expanded () {
280
293
                var resList = new ArrayList<FileEntry> ();
281
294
                ArrayList<FileEntry> wcEntries = new ArrayList<FileEntry> ();
297
310
                        // rootdir might contain relative paths...
298
311
                        dir = real_path (dir);
299
312
 
300
 
                        HashSet<string> files = find_files (dir, true);
 
313
                        // find files, not recursively
 
314
                        HashSet<string> files = find_files (dir, false);
301
315
 
302
316
                        resList.remove (fe);
303
317
                        if (files == null)
306
320
                        foreach (string s in files) {
307
321
                                string ematch = Path.build_filename ("*", fe.fname, null);
308
322
                                if (PatternSpec.match_simple (ematch, s)) {
309
 
                                        FileEntry e = new FileEntry ();
310
 
 
311
 
                                        // Create secure filenames, so Listaller doesn't try to rename files with spaces in their name
312
 
                                        var fs = s;
313
 
                                        if (fs.index_of (" ") > 0)
314
 
                                                fs = "'%s'".printf (fs);
315
 
 
316
 
                                        e.fname = fs;
317
 
                                        e.destination = Path.build_filename (fe.destination, Path.get_dirname (s).replace (dir, ""), null);
318
 
                                        resList.add (e);
 
323
                                        // in case the wildcard matched a directory, we add the whole thing
 
324
                                        if (FileUtils.test (s, FileTest.IS_DIR)) {
 
325
                                                HashSet<string> subfiles = find_files (s, true);
 
326
                                                foreach (string sf in subfiles) {
 
327
                                                        refine_fileentry_add_to_list (resList, fe, dir, sf);
 
328
                                                }
 
329
                                        } else {
 
330
                                                // else just add the matched file
 
331
                                                refine_fileentry_add_to_list (resList, fe, dir, s);
 
332
                                        }
319
333
                                }
320
334
                        }
321
335
                }