15.04.2014 - Version 0.3.8_beta, last version of 0.3.8 branch. Too much added and fixed...
This commit is contained in:
14
pifile.cpp
14
pifile.cpp
@@ -42,19 +42,27 @@
|
||||
|
||||
|
||||
bool PIFile::openDevice() {
|
||||
if (opened_) close();
|
||||
close();
|
||||
if (path_.isEmpty()) return false;
|
||||
//cout << "fopen " << path_.data() << ": " << strType(mode_).data() << endl;
|
||||
//piCout << "fopen " << path_.data() << ": " << strType(mode_).data() << fd;
|
||||
fd = fopen(path_.data(), strType(mode_).data());
|
||||
opened_ = (fd != 0);
|
||||
#ifndef WINDOWS
|
||||
if (opened_) fcntl(fileno(fd), F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
seekToBegin();
|
||||
//piCout << "open file" << fd << opened_;
|
||||
return opened_;
|
||||
}
|
||||
|
||||
|
||||
bool PIFile::closeDevice() {
|
||||
//piCout << "close file" << fd << opened_;
|
||||
if (!opened_ || fd == 0) return true;
|
||||
return (fclose(fd) == 0);
|
||||
bool cs = (fclose(fd) == 0);
|
||||
if (cs) fd = 0;
|
||||
//piCout << "closed file" << fd << opened_;
|
||||
return cs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user