Ejemplo n.º 1
0
BOOL build_app_bundle(const char *unix_link, const char *dir, const char *link, const char *link_name, const char *path, const char *args, const char *workdir, char **icon)
{
    BOOL ret = FALSE;
    char *path_to_bundle, *path_to_macos, *path_to_script, *path_to_info, *path_to_resources;
    CFDictionaryRef info = NULL;

    path_to_bundle = heap_printf("%s/%s.app", dir, link);
    if (!path_to_bundle)
        return FALSE;
    path_to_macos = heap_printf("%s/Contents/MacOS", path_to_bundle);
    path_to_script = heap_printf("%s/Contents/MacOS/winelauncher", path_to_bundle);
    path_to_info = heap_printf("%s/Contents/Info.plist", path_to_bundle);
    path_to_resources = heap_printf("%s/Contents/Resources", path_to_bundle);
    if (!path_to_macos || !path_to_script || !path_to_info || !path_to_resources)
        goto out;

    if (!create_directories(path_to_macos) || !create_directories(path_to_resources))
        goto out;

    if (!generate_bundle_script(path_to_script, path, args, workdir))
        goto out;

    info = create_info_plist_dictionary(link_name, *icon);
    if (!info)
        goto out;

    if (!write_property_list(path_to_info, info, kCFPropertyListXMLFormat_v1_0))
        goto out;

    if (*icon)
    {
        char *tmp = heap_printf("%s/%s", path_to_resources, *icon);

        if (!tmp)
            goto out;
        HeapFree(GetProcessHeap(), 0, *icon);
        *icon = tmp;
    }

    if (unix_link)
    {
        DWORD r = register_menus_entry(path_to_bundle, unix_link);
        if (r != ERROR_SUCCESS)
            goto out;
    }

    ret = TRUE;

out:
    if (ret == FALSE)
        remove_unix_link(path_to_bundle);
    HeapFree(GetProcessHeap(), 0, path_to_bundle);
    HeapFree(GetProcessHeap(), 0, path_to_macos);
    HeapFree(GetProcessHeap(), 0, path_to_script);
    HeapFree(GetProcessHeap(), 0, path_to_info);
    HeapFree(GetProcessHeap(), 0, path_to_resources);
    if (info)
        CFRelease(info);
    return ret;
}
Ejemplo n.º 2
0
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));
}
Ejemplo n.º 3
0
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);
				}
			}
Ejemplo n.º 4
0
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());
}
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
/***********************************************************************
 *            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;
}
Ejemplo n.º 7
0
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;
}
Ejemplo n.º 8
0
static BOOL appbundle_init(void)
{
    WCHAR shellDesktopPath[MAX_PATH];

    HRESULT hr = SHGetFolderPathW(NULL, CSIDL_DESKTOP, NULL, SHGFP_TYPE_CURRENT, shellDesktopPath);
    if (SUCCEEDED(hr))
        mac_desktop_dir = wine_get_unix_file_name(shellDesktopPath);

    if (mac_desktop_dir == NULL)
    {
        WINE_ERR("error looking up the desktop directory\n");
        return FALSE;
    }

    if (getenv("WINE_APPLICATIONS_DIR"))
        wine_applications_dir = strdupA(getenv("WINE_APPLICATIONS_DIR"));
    else
        wine_applications_dir = heap_printf("%s/Applications/Wine", getenv("HOME"));
    if (!wine_applications_dir)
        return FALSE;

    create_directories(wine_applications_dir);
    WINE_TRACE("Applications in %s\n", wine_applications_dir);

    return TRUE;
}
Ejemplo n.º 9
0
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';
}
Ejemplo n.º 10
0
/* 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;
}
Ejemplo n.º 11
0
TEST_F(ClientMetadataTest, TestCreateIndices) {
  start(4, 1);
  create_directories("/foo/bar/test");
  create_directories("/foo/bar/zoo");

  EXPECT_TRUE(client_->create_index("/foo/bar", "blue", IndexInfo::BTREE,
                                  INT32, 0755, 100, 100).ok());
  EXPECT_TRUE(client_->create_index("/foo/bar", "蓝色", IndexInfo::BTREE,
                                    INT32, 0755, 100, 100).ok());
  EXPECT_TRUE(client_->create_index("/foo/bar/zoo", "blue", IndexInfo::BTREE,
                                  INT32, 0755, 100, 100).ok());
  struct stat stbuf;
  EXPECT_TRUE(client_->getattr("/foo/bar/.vsfs/blue", &stbuf).ok());
  EXPECT_TRUE(client_->getattr("/foo/bar/.vsfs/蓝色", &stbuf).ok());
  EXPECT_TRUE(client_->getattr("/foo/bar/zoo/.vsfs/blue", &stbuf).ok());
}
Ejemplo n.º 12
0
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);
	}

}
Ejemplo n.º 13
0
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>() );
    }
}
Ejemplo n.º 14
0
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);
		}
	}
}
Ejemplo n.º 15
0
		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;
		}
    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);
    }
    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"));
        }
    }
Ejemplo n.º 18
0
bool FilePath::createDirectories(const UString &path) {
	try {
		return create_directories(path.c_str());
	} catch (std::exception &se) {
		throw Exception(se);
	}
}
Ejemplo n.º 19
0
TEST_F(ClientMetadataTest, TestSearchUTF8Indices) {
  start(2, 2);
  create_index("/foo/bar", "测试");
  create_directories("/foo/bar/dog");
  for (int i = 0; i < 100; i++) {
    ObjectId oid;
    client_->create("/foo/bar/dog/dog" + 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/dog/dog" + to_string(i),
                          "测试",
                          to_string(i));
  }
  LOG(INFO) << "Update request;";
  EXPECT_TRUE(client_->update(requests).ok());

  ComplexQuery query;
  EXPECT_TRUE(query.parse("/foo?测试>50").ok());
  vector<string> actual_files;
  EXPECT_TRUE(client_->search(query, &actual_files).ok());
  EXPECT_EQ(49u, actual_files.size());
}
    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"));
        }
    }
Ejemplo n.º 21
0
    void outputStateMatlab(const UnstructuredGrid& grid,
                           const Opm::SimulationDataContainer& state,
                           const int step,
                           const std::string& output_dir)
    {
        Opm::DataMap dm;
        dm["saturation"] = &state.saturation();
        dm["pressure"] = &state.pressure();
        for (const auto& pair : state.cellData()) {
            const std::string& name = pair.first;
            std::string key;
            if( name == "SURFACEVOL" ) {
                key = "surfvolume";
            }
            else if( name == "RV" ) {
                key = "rv";
            }
            else if( name == "GASOILRATIO" ) {
                key = "rs";
            }
            else { // otherwise skip entry
                continue;
            }
            // set data to datmap
            dm[ key ] = &pair.second;
        }

        std::vector<double> cell_velocity;
        Opm::estimateCellVelocity(AutoDiffGrid::numCells(grid),
                                  AutoDiffGrid::numFaces(grid),
                                  AutoDiffGrid::beginFaceCentroids(grid),
                                  UgGridHelpers::faceCells(grid),
                                  AutoDiffGrid::beginCellCentroids(grid),
                                  AutoDiffGrid::beginCellVolumes(grid),
                                  AutoDiffGrid::dimensions(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"));
        }
    }
Ejemplo n.º 22
0
	void Start() override {
		if (!RpcUrl.get_Port())
			RpcUrl = Uri("http://127.0.0.1:" + Convert::ToString(GetFreePort()));
		else {
			try {
				DBG_LOCAL_IGNORE_CONDITION(errc::connection_refused);

				Call("getinfo");			

				if (!PathDaemon.empty()) {
					try {
						vector<Process> ps = Process::GetProcessesByName(PathDaemon.stem().c_str());	//!!! incorrect process can be selected and then terminated
						if (!ps.empty())
							m_process = ps.back();
					} catch (RCExc) {
					}
				}
				return;
			} catch (system_error& DBG_PARAM(ex)) {
				TRC(1, ex.code() << " " << ex.what());
			}
		}

		if (PathDaemon.empty()) {
			LOG("Currency daemon for " << Name << " is unavailable");
			return;
		}
		if (m_process) {
			if (!m_process.HasExited)
				return;
			TRC(2, "Process " << m_process.get_ID() << " exited with code " << m_process.get_ExitCode());
		}
		
		String exeFilePath = System.get_ExeFilePath();
		ostringstream os;
		create_directories(DataDir);
		Listen ? (os << " -port=" << GetFreePort()) : (os << " -listen=0");
		os << " -rpcport=" << RpcUrl.get_Port()
			<< " -rpcallowip=127.0.0.1"
			<< " -rpcuser="******" -rpcpassword="******" -daemon"
			<< " -server"
			<< (IsTestNet ? " -testnet" : "")
			<< " -datadir=\"" << DataDir << "\"";
		if (EnableNotifications) {
			os << " -blocknotify=\"" << exeFilePath << " " << EpApi << " blocknotify " << Name << " %s\""
			<< " -alertnotify=\"" << exeFilePath << " " << EpApi << " alertnotify " << Name << " %s\"";		
			if (WalletNotifications)
				os << " -walletnotify=\"" << exeFilePath << " " << EpApi <<  " walletnotify " << Name << " %s\"";
		}
		if (!Args.empty())
			os << " " << Args;
		ProcessStartInfo psi;
		psi.Arguments = os.str();
		psi.FileName = PathDaemon;
		psi.EnvironmentVariables["ComSpec"] = exeFilePath;										// to avoid console window
		m_process = Process::Start(psi);
	}
Ejemplo n.º 23
0
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());
}
Ejemplo n.º 24
0
// 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;
}
Ejemplo n.º 25
0
bool
zathura_init(zathura_t* zathura)
{
  if (zathura == NULL) {
    return false;
  }

  /* create zathura (config/data) directory */
  create_directories(zathura);

  /* load plugins */
  zathura_plugin_manager_load(zathura->plugins.manager);

  /* configuration */
  config_load_default(zathura);
  config_load_files(zathura);

  /* UI */
  if (!init_ui(zathura)) {
    goto error_free;
  }

  /* database */
  init_database(zathura);

  /* bookmarks */
  zathura->bookmarks.bookmarks = girara_sorted_list_new2(
    (girara_compare_function_t)zathura_bookmarks_compare,
    (girara_free_function_t)zathura_bookmark_free);

  /* jumplist */
  init_jumplist(zathura);

  /* CSS for index mode */
  init_css(zathura);

  /* Shortcut helpers */
  init_shortcut_helpers(zathura);

  /* Start D-Bus service */
  bool dbus = true;
  girara_setting_get(zathura->ui.session, "dbus-service", &dbus);
  if (dbus == true) {
    zathura->dbus = zathura_dbus_new(zathura);
  }

  return true;

error_free:

  if (zathura->ui.page_widget != NULL) {
    g_object_unref(zathura->ui.page_widget);
  }

  return false;
}
Ejemplo n.º 26
0
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_ );
}
Ejemplo n.º 27
0
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);
}
Ejemplo n.º 28
0
	bool FileSystem::CreateDirectory_(const string& path)
	{
		try
		{
			return create_directories(path);
		}
		catch (filesystem_error& e)
		{
			LOGF_ERROR("FileSystem::CreateDirectory: %s, %s", e.what(), path.c_str());
			return true;
		}
	}
Ejemplo n.º 29
0
Status ObjectStorageManager::init() {
  // Creates subdirs if not existed.
  for (int i = 0; i < num_subdirs_; i++) {
    auto subdir = fs::path(base_path_) / to_string(i);
    boost::system::error_code ec;
    create_directories(subdir, ec);
    if (ec.value() > 0) {
      return Status(ec.value(), ec.message());
    }
  }
  return Status::OK;
}
Ejemplo n.º 30
0
TEST_F(TransformQueryTest, GraphViz)
{
  boost::filesystem::path dotfile = PROJECT_BINARY_DIR "/ome-xml/src/test/cpp/data/ome-transforms.dot";
  boost::filesystem::path dotdir = dotfile.parent_path();
  if (!exists(dotdir) && !is_directory(dotdir) && !create_directories(dotdir))
    throw std::runtime_error("Data directory unavailable and could not be created");

  std::ofstream dotstream(dotfile.string().c_str());

  resolver.write_graphviz(dotstream);
  resolver.write_graphviz(std::cout);
}