예제 #1
0
파일: file.hpp 프로젝트: artas360/pythran
 void file::write(types::str const &str)
 {
   if (not is_open)
     throw ValueError("I/O operation on closed file");
   if (mode.find_first_of("wa+") == -1)
     throw IOError("file.write() :  File not opened for writing.");
   fwrite(str.c_str(), sizeof(char), str.size(), **data);
 }
예제 #2
0
파일: file.hpp 프로젝트: artas360/pythran
    // Modifiers
    void file::open(types::str const &filename, types::str const &strmode)
    {
      const char *smode = strmode.c_str();
      // Python enforces that the mode, after stripping 'U', begins with 'r',
      // 'w' or 'a'.
      if (*smode == 'U') {
        ++smode;
      } // Not implemented yet

      data = utils::shared_ref<container_type>(filename, smode);
      if (not**data)
        throw types::IOError("Couldn't open file " + filename);
      is_open = true;
    }
예제 #3
0
파일: file.hpp 프로젝트: artas360/pythran
 _file::_file(types::str const &filename, types::str const &strmode)
     : f(fopen(filename.c_str(), strmode.c_str())), _buffer(nullptr),
       _buffer_size(0)
 {
 }
예제 #4
0
파일: file.hpp 프로젝트: LuisBL/pythran
 // TODO : no check on file existance?
 _file::_file(types::str const &filename, types::str const &strmode)
     : f(fopen(filename.c_str(), strmode.c_str()))
 {
 }