本文整理汇总了C++中create_directories函数的典型用法代码示例。如果您正苦于以下问题:C++ create_directories函数的具体用法?C++ create_directories怎么用?C++ create_directories使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_directories函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(ClientMetadataTest, TestSearchSuccess) {
start(4, 4);
create_index("/foo/bar", "dog");
create_directories("/foo/bar/zoo");
create_directories("/foo/bar/dogs");
create_directories("/foo/bar/cat");
for (int i = 0; i < 100; i++) {
ObjectId oid;
client_->create("/foo/bar/zoo/zoo" + to_string(i), 0644, 100, 100, &oid);
client_->create("/foo/bar/dogs/dog" + to_string(i), 0644, 100, 100, &oid);
client_->create("/foo/bar/cat/cat" + to_string(i), 0644, 100, 100, &oid);
}
vector<VSFSRpcClient::IndexUpdateRequest> requests;
for (int i = 0; i < 100; i++) {
requests.emplace_back(VSFSRpcClient::IndexUpdateRequest::INSERT,
"/foo/bar/dogs/dog" + to_string(i),
"dog",
to_string(i));
}
EXPECT_TRUE(client_->update(requests).ok());
vector<string> expected_files;
for (int i = 51; i < 100; i++) {
expected_files.push_back("/foo/bar/dogs/dog" + to_string(i));
}
ComplexQuery query;
query.parse("/foo?dog>50");
vector<string> actual_files;
EXPECT_TRUE(client_->search(query, &actual_files).ok());
sort(actual_files.begin(), actual_files.end());
EXPECT_THAT(actual_files, ContainerEq(expected_files));
}
开发者ID:vsfs,项目名称:vsfs,代码行数:35,代码来源:client_metadata_test.cpp
示例2: findUserPath
static path findUserPath(const char * name, const path & force,
const char * registry, const char * prefix,
const char * suffix, const path & fallback,
bool create) {
// Prefer command-line options
if(!force.empty()) {
path dir = canonical(force);
if(create && !create_directories(dir)) {
LogCritical << "Could not create " << name << " directory " << dir << '.';
return path();
} else {
LogDebug("using " << name << " dir from command-line: " << dir);
return dir;
}
}
// Check system settings (windows registry)
std::string temp;
if(registry && platform::getSystemConfiguration(registry, temp)) {
path dir = canonical(temp);
if(!create) {
return dir;
} else if(create_directories(dir)) {
LogDebug("got " << name << " dir from registry: \"" << temp
<< "\" = " << dir);
return dir;
} else {
LogError << "Could not create " << name << " directory " << dir << '.';
LogDebug("ignoring " << name << " dir from registry: \"" << temp << '"');
}
}
// Search standard locations
path to_create;
std::vector<path> prefixes = getSearchPaths(prefix);
std::vector<path> suffixes = getSearchPaths(suffix);
if(prefix || suffix) {
bool create_exists = false;
BOOST_FOREACH(const path & prefix, prefixes) {
BOOST_FOREACH(const path & suffix, suffixes) {
path dir = canonical(prefix / suffix);
if(is_directory(dir)) {
LogDebug("got " << name << " dir from search: " << prefix
<< " + " << suffix << " = " << dir);
return dir;
} else {
LogDebug("ignoring " << name << " dir from search: " << prefix
<< " + " << suffix << " = " << dir);
}
if(to_create.empty() || (!create_exists && is_directory(prefix))) {
to_create = dir;
create_exists = is_directory(prefix);
}
}
开发者ID:Gladius1,项目名称:ArxLibertatis,代码行数:58,代码来源:SystemPaths.cpp
示例3: create_directories
bool JobDir::create(fs::path const& base_dir) try
{
return
create_directories(base_dir / fs::path(tmp_tag, fs::native))
&& create_directories(base_dir / fs::path(new_tag, fs::native))
&& create_directories(base_dir / fs::path(old_tag, fs::native));
} catch (boost::filesystem::filesystem_error const& e) {
throw JobDirError(e.what());
}
开发者ID:ic-hep,项目名称:emi3,代码行数:9,代码来源:jobdir.cpp
示例4: Options
bool MainForm::load_settings() {
options = new Options();
if (!options->read()) {
options = DEFAULT_SETTINGS;
}
edit_username->setText(options->get_hoster()->get_username().c_str());
edit_password->setText(options->get_hoster()->get_password().c_str());
mpv_settings->setPlainText(options->mpv_settings.c_str());
//todo hoster
edit_down_speed->setValue(options->download_speed / 1024.0 / 1024.0);
edit_memory->setValue(options->memory / 1024.0 / 1024.0);
archive_directory->setFile(options->archive_directory.c_str());
download_directory->setFile(options->download_directory.c_str());
QFileInfo file(options->archive_directory.c_str());
create_directories(file.absoluteDir().absolutePath());
create_directories(options->download_directory.c_str());
disclaimer = options->disclaimer;
bool first_run = disclaimer;
if (disclaimer) {
QMessageBox box;
box.setText(
"I will not take any responsibility for any of your actions. This program is maybe against your state's law.");
box.setWindowTitle("Disclaimer");
box.setIcon(QMessageBox::Information);
QPushButton *ok_button = box.addButton("Yes, I understand.", QMessageBox::ActionRole);
QPushButton *abortButton = box.addButton("Terminate this programm.", QMessageBox::ActionRole);
box.exec();
if (box.clickedButton() == ok_button) {
disclaimer = false;
} else if (box.clickedButton() == abortButton) {
disclaimer = true;
}
}
options->disclaimer = disclaimer;
options->write();
return first_run;
}
开发者ID:maxammann,项目名称:aqueduct,代码行数:49,代码来源:settings.cpp
示例5: create_fake_dll
/***********************************************************************
* create_fake_dll
*/
BOOL create_fake_dll( const WCHAR *name, const WCHAR *source )
{
HANDLE h;
HMODULE module;
BOOL ret;
/* check for empty name which means to only create the directory */
if (name[strlenW(name) - 1] == '\\')
{
create_directories( name );
return TRUE;
}
/* first check for an existing file */
h = CreateFileW( name, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
if (h != INVALID_HANDLE_VALUE)
{
if (!is_fake_dll( h ))
{
TRACE( "%s is not a fake dll, not overwriting it\n", debugstr_w(name) );
CloseHandle( h );
return TRUE;
}
/* truncate the file */
SetFilePointer( h, 0, NULL, FILE_BEGIN );
SetEndOfFile( h );
}
else
{
if (GetLastError() == ERROR_PATH_NOT_FOUND) create_directories( name );
h = CreateFileW( name, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL );
if (h == INVALID_HANDLE_VALUE)
{
ERR( "failed to create %s (error=%u)\n", debugstr_w(name), GetLastError() );
return FALSE;
}
}
module = LoadLibraryW( source );
ret = build_fake_dll( h, module );
CloseHandle( h );
if (module) FreeLibrary( module );
if (!ret) DeleteFileW( name );
return ret;
}
开发者ID:WASSUM,项目名称:longene_travel,代码行数:51,代码来源:fakedll.c
示例6: ConvertToDDS
std::string ConvertToDDS(const char *filePath, filepath &baseDirectory, filepath &rootInputDirectory, filepath &rootOutputDirectory) {
filepath relativePath(filePath);
filepath relativeDDSPath(relativePath);
relativeDDSPath.replace_extension("dds");
// If the file already exists in the output directory, we don't need to do anything
filepath outputFilePath(rootOutputDirectory.file_string() + "\\" + relativeDDSPath.file_string());
if (exists(outputFilePath)) {
return relativeDDSPath;
}
// Guarantee the output directory exists
filepath outputDirectory(outputFilePath.parent_path());
create_directories(outputDirectory);
// If input is already dds, but doesn't exist in the output directory, just copy the file to the output
filepath inputFilePath(rootInputDirectory.file_string() + "\\" + relativePath.file_string());
if (_stricmp(relativePath.extension().c_str(), "dds") == 0) {
copy_file(inputFilePath, outputFilePath);
return relativeDDSPath;
}
// Otherwise, convert the file to DDS
std::string call = baseDirectory.file_string() + "\\texconv.exe -ft dds -o " + outputDirectory.file_string() + " " + inputFilePath.file_string() + " > NUL";
std::system(call.c_str());
return relativeDDSPath;
}
开发者ID:RichieSams,项目名称:thehalflingproject,代码行数:28,代码来源:util.cpp
示例7: main
int main(int argc, char* argv[])
try {
std::ios_base::sync_with_stdio(false);
if (argc < 2 || 4 < argc)
throw std::runtime_error{
"Usage: ulgp source [destination] [file pattern]"
};
fs::path arg1{fs::canonical(argv[1])};
std::regex pattern{argc == 4 ? argv[3] : ".*"};
if (fs::is_regular_file(arg1)) {
auto folder = argc < 3 ? arg1.parent_path() / arg1.stem() : argv[2];
create_directories(folder);
current_path(folder);
extract(arg1, pattern);
} else if (fs::is_directory(arg1)) {
auto lgp = argc < 3 ? arg1.string() + ".lgp" : fs::absolute(argv[2]);
current_path(arg1);
add(lgp, pattern);
} else
throw std::runtime_error{
"Lgp file / folder not found."
};
} catch (std::exception const& e) {
std::cerr << e.what() << '\n';
}
开发者ID:ser-pounce,项目名称:ff7-tools,代码行数:35,代码来源:ulgp.exe.cpp
示例8: create_dest_file
/* create the fake dll destination file */
static HANDLE create_dest_file( const WCHAR *name )
{
/* first check for an existing file */
HANDLE h = CreateFileW( name, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );
if (h != INVALID_HANDLE_VALUE)
{
if (!is_fake_dll( h ))
{
TRACE( "%s is not a fake dll, not overwriting it\n", debugstr_w(name) );
CloseHandle( h );
return 0;
}
/* truncate the file */
SetFilePointer( h, 0, NULL, FILE_BEGIN );
SetEndOfFile( h );
}
else
{
if (GetLastError() == ERROR_PATH_NOT_FOUND) create_directories( name );
h = CreateFileW( name, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL );
if (h == INVALID_HANDLE_VALUE)
ERR( "failed to create %s (error=%u)\n", debugstr_w(name), GetLastError() );
}
return h;
}
开发者ID:AlexSteel,项目名称:wine,代码行数:27,代码来源:fakedll.c
示例9: m_app
CSessionStorage::CSessionStorage(CSession* session) : m_app(muroa::CApp::getInstPtr()),
m_session(session)
{
m_storage_path = m_app->settings().getConfigVal("msessiond.sessions_storage_dir", "");
m_storage_path = CUtils::expandvars(m_storage_path);
m_storage_path/=m_session->getName();
LOG4CPLUS_INFO(m_app->logger(), "session storage in " << m_storage_path << endl );
if(!exists(m_storage_path) || !is_directory(m_storage_path)) {
create_directories(m_storage_path);
}
if(!exists(m_storage_path/mediaColSubdir)) {
create_directory(m_storage_path/mediaColSubdir);
}
if(!exists(m_storage_path/playlistSubdir)) {
create_directory(m_storage_path/playlistSubdir);
}
if(!exists(m_storage_path/nextlistSubdir)) {
create_directory(m_storage_path/nextlistSubdir);
}
if(!exists(m_storage_path/sessionStateSubdir)) {
create_directory(m_storage_path/sessionStateSubdir);
}
}
开发者ID:martinrunge,项目名称:muroa,代码行数:30,代码来源:CSessionStorage.cpp
示例10: initialize
void Wallpaper::initialize()
{
if ( !m_directory.empty() )
{
return;
}
po::variables_map& vm = IConfigurationFile::instance().variables_map();
if ( vm.count( wallpaper_path ) )
{
m_directory = fs::system_complete( vm[wallpaper_path].as<std::wstring>() );
}
if ( vm.count( wallpaper_recycle_path ) )
{
m_recycle_directory = fs::system_complete( vm[wallpaper_recycle_path].as<std::wstring>() );
if ( ! m_recycle_directory.empty() && ! exists( m_recycle_directory ) )
{
boost::system::error_code ec;
if ( ! create_directories( m_recycle_directory, ec ) )
{
m_recycle_directory.clear();
}
}
}
if ( vm.count( wallpaper_check_picture ) )
{
m_check_picture = ( L"true" == vm[wallpaper_check_picture].as<std::wstring>() );
}
}
开发者ID:limin-git,项目名称:Review4,代码行数:33,代码来源:Wallpaper.cpp
示例11: try_run_file
void try_run_file(const boost::filesystem::path & cur)
{
if(cur.extension().native().compare(".py"))
{
return;
}
script_file_parser script_file(cur.native());
if(script_file.is_valid())
{
boost::filesystem::path work, out;
create_directories(cur, work, out);
auto parent = cur.parent_path();
auto start = parent.begin();
for(auto p = config::tests.begin(); p != config::tests.end() && *p == *start; ++p, ++start) ;
for(; start != parent.end(); ++start)
{
script_file.add_keyword((*start).native());
}
script_file.add_title(cur.stem().native());
if(config::query->evaluate(script_file))
{
script_scheduler()->schedule_file(cur, work, out);
}
}
}
开发者ID:pdJeeves,项目名称:MCell-Test-Framework,代码行数:32,代码来源:main.cpp
示例12: move_log_file
void move_log_file(std::string const& logpath, std::string const& new_name, int instance)
{
mutex::scoped_lock l(file_mutex);
if (open_filename == m_filename)
{
log_file.close();
open_filename.clear();
}
char log_name[512];
snprintf(log_name, sizeof(log_name), "libtorrent_logs%d", instance);
std::string dir(combine_path(combine_path(complete(logpath), log_name), new_name) + ".log");
error_code ec;
create_directories(parent_path(dir), ec);
if (ec)
fprintf(stderr, "Failed to create logfile directory %s: %s\n"
, parent_path(dir).c_str(), ec.message().c_str());
ec.clear();
rename(m_filename, dir, ec);
if (ec)
fprintf(stderr, "Failed to move logfile %s: %s\n"
, parent_path(dir).c_str(), ec.message().c_str());
m_filename = dir;
}
开发者ID:771805315,项目名称:avplayer,代码行数:27,代码来源:debug.hpp
示例13: outputStateVtk
static void outputStateVtk(const UnstructuredGrid& grid,
const Opm::BlackoilState& state,
const int step,
const std::string& output_dir)
{
// Write data in VTK format.
std::ostringstream vtkfilename;
vtkfilename << output_dir << "/vtk_files";
boost::filesystem::path fpath(vtkfilename.str());
try {
create_directories(fpath);
}
catch (...) {
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
}
vtkfilename << "/output-" << std::setw(3) << std::setfill('0') << step << ".vtu";
std::ofstream vtkfile(vtkfilename.str().c_str());
if (!vtkfile) {
OPM_THROW(std::runtime_error, "Failed to open " << vtkfilename.str());
}
Opm::DataMap dm;
dm["saturation"] = &state.saturation();
dm["pressure"] = &state.pressure();
std::vector<double> cell_velocity;
Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
dm["velocity"] = &cell_velocity;
Opm::writeVtkData(grid, dm, vtkfile);
}
开发者ID:jokva,项目名称:opm-simulators,代码行数:29,代码来源:SimulatorCompressibleTwophase.cpp
示例14: outputStateMatlab
static void outputStateMatlab(const UnstructuredGrid& grid,
const Opm::BlackoilState& state,
const int step,
const std::string& output_dir)
{
Opm::DataMap dm;
dm["saturation"] = &state.saturation();
dm["pressure"] = &state.pressure();
dm["surfvolume"] = &state.surfacevol();
std::vector<double> cell_velocity;
Opm::estimateCellVelocity(grid, state.faceflux(), cell_velocity);
dm["velocity"] = &cell_velocity;
// Write data (not grid) in Matlab format
for (Opm::DataMap::const_iterator it = dm.begin(); it != dm.end(); ++it) {
std::ostringstream fname;
fname << output_dir << "/" << it->first;
boost::filesystem::path fpath = fname.str();
try {
create_directories(fpath);
}
catch (...) {
OPM_THROW(std::runtime_error, "Creating directories failed: " << fpath);
}
fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt";
std::ofstream file(fname.str().c_str());
if (!file) {
OPM_THROW(std::runtime_error, "Failed to open " << fname.str());
}
file.precision(15);
const std::vector<double>& d = *(it->second);
std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
}
}
开发者ID:jokva,项目名称:opm-simulators,代码行数:34,代码来源:SimulatorCompressibleTwophase.cpp
示例15: create_directories
bool FilePath::createDirectories(const UString &path) {
try {
return create_directories(path.c_str());
} catch (std::exception &se) {
throw Exception(se);
}
}
开发者ID:berenm,项目名称:xoreos,代码行数:7,代码来源:filepath.cpp
示例16: outputWellStateMatlab
void outputWellStateMatlab(const Opm::WellState& well_state,
const int step,
const std::string& output_dir)
{
Opm::DataMap dm;
dm["bhp"] = &well_state.bhp();
dm["wellrates"] = &well_state.wellRates();
// Write data (not grid) in Matlab format
for (Opm::DataMap::const_iterator it = dm.begin(); it != dm.end(); ++it) {
std::ostringstream fname;
fname << output_dir << "/" << it->first;
boost::filesystem::path fpath = fname.str();
try {
create_directories(fpath);
}
catch (...) {
OPM_THROW(std::runtime_error,"Creating directories failed: " << fpath);
}
fname << "/" << std::setw(3) << std::setfill('0') << step << ".txt";
std::ofstream file(fname.str().c_str());
if (!file) {
OPM_THROW(std::runtime_error,"Failed to open " << fname.str());
}
file.precision(15);
const std::vector<double>& d = *(it->second);
std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
}
}
开发者ID:flikka,项目名称:opm-autodiff,代码行数:29,代码来源:SimulatorFullyImplicitBlackoilOutput.cpp
示例17: extract_file
void extract_file(ff7::lgp::Archive::value_type const& file)
{
fs::path path{file.first};
if (path.has_parent_path())
create_directories(path.parent_path());
std::ofstream stream(file.first, std::ios::binary);
util::write(stream, file.second->data());
}
开发者ID:ser-pounce,项目名称:ff7-tools,代码行数:9,代码来源:ulgp.exe.cpp
示例18: NormalMode
// compiles all files
bool opDriver::NormalMode(const opParameters& p) {
// verify the output directory...
path dirpath = p.GeneratedDirectory.GetString();
if (!exists(dirpath)) create_directories(dirpath);
opSet<path> files = GetFiles();
// if there are no files to compile, return false
if (files.size() == 0) {
if (!p.Silent) Log("Error: No files to compile!");
return false;
}
// compile all files
bool bResult = true;
typedef opSet<path>::const_iterator fileit;
if (p.Verbose) // spacing in verbose mode
Log(' ');
for (fileit it = files.begin(); it != files.end(); ++it) {
bResult = NormalModeFile(p, *it) ? bResult : false;
}
// If we had errors, print out the number of errors.
if (NumErrors > 0) {
Log("");
string errorstring = (NumErrors == 1) ? " error" : " errors";
Log("opC++ - " + opString(NumErrors) + errorstring);
Log("");
}
if (!p.Silent && files.size() > 1) {
if (p.Verbose) {
Log(' ');
if (bResult) {
Log("opC++ - 0 errors");
Log("");
Log("--------------------------------");
Log("All Files Compiled Successfully!");
Log("--------------------------------");
} else {
Log("-------------------------------------");
Log("Some File(s) Compiled Unsuccessfully!");
Log("-------------------------------------");
}
Log(' ');
}
}
return bResult;
}
开发者ID:it3ration,项目名称:opcpp,代码行数:58,代码来源:driver.cpp
示例19: LOG
void
vca_illegal_parking::init()
{
LOG ( INFO ) << "vca_illegal_parking[" << name_ << "]: initializing...";
working_dir_ = operator/( global::config()->get ( "vca.data_dir", "data" ), name_ );
create_directories ( working_dir_ );
event_queue_.reset( new squeue< shared_ptr< ptree > >() );
loiter_->subscribe ( event_queue_ );
}
开发者ID:khoinguyentran,项目名称:hdb-node,代码行数:11,代码来源:vca_illegal_parking.cpp
示例20: TEST_F
TEST_F(TransformQueryTest, OmeTransformsXML)
{
boost::filesystem::path xmlfile = PROJECT_BINARY_DIR "/ome-xml/src/test/cpp/data/ome-transforms.xml";
boost::filesystem::path xmldir = xmlfile.parent_path();
if (!exists(xmldir) && !is_directory(xmldir) && !create_directories(xmldir))
throw std::runtime_error("Data directory unavailable and could not be created");
std::ofstream xmlstream(xmlfile.string().c_str());
write_ome_transforms(resolver, xmlstream);
write_ome_transforms(resolver, std::cout);
}
开发者ID:sbesson,项目名称:ome-model,代码行数:12,代码来源:transform-resolver.cpp
注:本文中的create_directories函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论