bulkrename

Bulk file/directory renaming utility, similar to ranger's built-in bulkrename command
git clone git://git.deurzen.net/bulkrename
Log | Files | Refs | LICENSE

file.hh (775B)


      1 #ifndef __BULKRENAME_FILE_GUARD__
      2 #define __BULKRENAME_FILE_GUARD__
      3 
      4 #include "node.hh"
      5 
      6 #include <fstream>
      7 #include <string.h>
      8 #include <iostream>
      9 #include <string>
     10 #include <cstdio>
     11 
     12 
     13 class filehandler_t
     14 {
     15 public:
     16     filehandler_t()
     17     {
     18         char* tmpname = strdup("/tmp/tmpfileXXXXXXXXXX");
     19         mkstemp(tmpname);
     20         tmpfile = tmpname;
     21         free(tmpname);
     22         out = ::std::ofstream(tmpfile);
     23     }
     24 
     25     ~filehandler_t()
     26     {
     27         out.close();
     28         in.close();
     29     }
     30 
     31     void write_out(const nodetree_t&);
     32     void read_in(const nodetree_t&);
     33 
     34     void edit() const;
     35     void propagate_rename(const nodetree_t&) const;
     36 
     37 private:
     38     ::std::string tmpfile;
     39     ::std::ifstream in;
     40     ::std::ofstream out;
     41 
     42 };
     43 
     44 #endif//__BULKRENAME_FILE_GUARD__