static bool IsOutputFile(const PathName& path) { PathName path_(path); if (path_.HasExtension(".gz")) { path_.SetExtension(nullptr); } return path_.HasExtension(".dvi") || path_.HasExtension(".pdf") || path_.HasExtension(".synctex"); }
bool CStorageDir::InitStorageDir(int dirid, int packbeginid, std::string strpath, CPreAllocateDisk *pdisk) { m_isHave = 1; m_storageDirID = dirid; m_packageBeginID = packbeginid; strcpy(m_storagePath, strpath.c_str()); m_pPreAllocateDisk = pdisk; try { fs::path path_(m_storagePath); if(fs::exists(path_) && fs::is_directory(path_)){} else { if(!fs::is_directory(path_)) fs::remove(path_); fs::create_directory(path_); } fs::path des_path_(strpath + s_allocInfoFileName); if (fs::exists(des_path_)) { return ReadStorageDirInfo(strpath + s_allocInfoFileName); } else { bool bret = CreateStorageDirInfo(strpath + s_allocInfoFileName); if( bret ) return WriteStorageDirInfo(strpath + s_allocInfoFileName); else return false; } } catch (const fs::filesystem_error& ex) { //std::cerr << ex.what() << '\n'; m_pPreAllocateDisk->m_log.Add("CStorageDir::InitStorageDir error = %s", ex.what()); return false; } return false; }
void Differ::paintOnImage(const QPainterPath &path, QImage *image) { QPainter painter(image); painter.setRenderHint(QPainter::Antialiasing); painter.setPen(pen); painter.setBrush(brush); QRectF rect = path.boundingRect(); if (rect.width() < squareSize && rect.height() < squareSize) { rect.setHeight(squareSize); rect.setWidth(squareSize); painter.drawRect(rect); } else { QPainterPath path_(path); path_.setFillRule(Qt::WindingFill); painter.drawPath(path_); } painter.end(); }
void configure(const std::wstring& filename) { try { auto separator = boost::filesystem::path::preferred_separator; auto initialPath = fs::initial_path<fs::path>().wstring(); std::wstring path_(initialPath + boost::lexical_cast<std::wstring>(separator) + filename); const wchar_t *pstr = path_.c_str(); std::wifstream file(reinterpret_cast<const char *>(pstr)); CASPAR_LOG(info) << L"before read_xml ..." << initialPath << " " << filename << " " << pstr; boost::property_tree::read_xml("/etc/casparcg.config", pt, boost::property_tree::xml_parser::trim_whitespace | boost::property_tree::xml_parser::no_comments); CASPAR_LOG(info) << L"read_xml done..."; auto paths = pt.get_child(L"configuration.paths"); media = widen(paths.get(L"media-path", initialPath + L"/media/")); log = widen(paths.get(L"log-path", initialPath + L"/log/")); ftemplate = fs::complete(fs::path(widen(paths.get(L"template-path", initialPath + L"/template/")))).wstring(); data = widen(paths.get(L"data-path", initialPath + L"/data/")); thumbnails = widen(paths.get(L"thumbnails-path", initialPath + L"/thumbnails/")); //Make sure that all paths have a trailing backslash if(media.at(media.length()-1) != L'/') media.append(L"/"); if(log.at(log.length()-1) != L'/') log.append(L"/"); if(ftemplate.at(ftemplate.length()-1) != L'/') ftemplate.append(L"/"); if(data.at(data.length()-1) != L'/') data.append(L"/"); if(thumbnails.at(thumbnails.length()-1) != L'/') thumbnails.append(L"/"); try { for(auto it = fs::directory_iterator(initialPath); it != fs::directory_iterator(); ++it) { if(it->path().filename().wstring().find(L".fth") != std::wstring::npos) { auto from_path = *it; auto to_path = fs::path(ftemplate + L'/' + it->path().filename().wstring()); if(fs::exists(to_path)) fs::remove(to_path); fs::copy_file(from_path, to_path); } } } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); CASPAR_LOG(error) << L"Failed to copy template-hosts from initial-path to template-path."; } } catch(...) { std::wcout << L" ### Invalid configuration file. ###"; throw; } try { auto media_path = fs::path(media); if(!fs::exists(media_path)) fs::create_directory(media_path); auto log_path = fs::path(log); if(!fs::exists(log_path)) fs::create_directory(log_path); auto template_path = fs::path(ftemplate); if(!fs::exists(template_path)) fs::create_directory(template_path); auto data_path = fs::path(data); if(!fs::exists(data_path)) fs::create_directory(data_path); auto thumbnails_path = fs::path(thumbnails); if(!fs::exists(thumbnails_path)) fs::create_directory(thumbnails_path); } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); CASPAR_LOG(error) << L"Failed to create configured directories."; } }
void makeDirectory(StringView path) noexcept { String path_(path); return makeDirectory(path_); }
bool isDir(StringView path) noexcept { String path_(path); return isDir(path_); }
Optional<uint64_t> getFileSize(StringView path) noexcept { String path_(path); return getFileSize(path_); }
bool writeFileVec(StringView path, uint32_t count, uint32_t* lengths, void** datas) noexcept { String path_(path); return writeFileVec(path_, count, lengths, datas); }
bool writeFile(StringView path, uint32_t length, void* data) noexcept { String path_(path); return writeFile(path_, length, data); }
Vector<String> listDir(StringView path) noexcept { String path_(path); return listDir(path_); }