bool File::setOpenMode(OpenMode openMode) { _mutex.lock(); if(_openMode == 0 || openMode == _openMode) return true; if(isOpen()) { FileImpl *impl = new FileImpl; if(!impl->open(_filePath, openMode)) { delete impl; return false; } _impl->close(); delete _impl; _impl = impl; } _openMode = openMode; return true; }
bool File::setPath(const String &filePath) { _mutex.lock(); if(isOpen()) { if(filePath.isEmpty()) return false; FileImpl *impl = new FileImpl; if(!impl->open(filePath, _openMode)) { delete _impl; return false; } _impl->close(); delete _impl; _impl = impl; } _filePath = absolutePath(filePath); return true; }