本文整理汇总了C++中boost::filesystem::path::wstring方法的典型用法代码示例。如果您正苦于以下问题:C++ path::wstring方法的具体用法?C++ path::wstring怎么用?C++ path::wstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::filesystem::path
的用法示例。
在下文中一共展示了path::wstring方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::wstring
path::posix( const boost::filesystem::path& path )
{
std::wstring temp = path.wstring();
std::transform( temp.begin(), temp.end(), temp.begin(), detail::forslash<wchar_t>() );
return temp;
}
示例2: Open
void CPsfRarArchive::Open(const boost::filesystem::path& filePath)
{
Archive* arc(ConvertArchive(m_archive));
arc->Open(filePath.wstring().c_str());
arc->IsArchive(false);
if(!arc->IsOpened())
{
throw std::runtime_error("Couldn't open archive.");
}
while(arc->ReadHeader() > 0)
{
if(arc->ShortBlock.HeaderType == HEAD_FILE)
{
if(!arc->IsArcDir())
{
FILEINFO fileInfo;
fileInfo.name = string_cast<std::string>(arc->FileHead.FileName);
boost::replace_all(fileInfo.name, "\\", "/");
fileInfo.length = static_cast<unsigned int>(arc->FileHead.UnpSize);
m_files.push_back(fileInfo);
}
}
arc->SeekToNext();
}
}
示例3:
std::string mf::utils::path_to_utf8(
const boost::filesystem::path & path
)
{
#ifdef _WIN32
return mf::utils::wide_to_bytes(path.wstring());
#else
return path.string();
#endif
}
示例4: JumpListAddRecentTask
bool JumpListAddRecentTask(JumpList& jumpList, fs::path const& ydweDirectory, fs::path const& filePath)
{
HRESULT hr = jumpList.AddTask(filePath.filename().c_str(), [&](CComPtr<IShellLinkW>& shellLinkPtr)
{
shellLinkPtr->SetPath((ydweDirectory / L"YDWE.exe").c_str());
shellLinkPtr->SetArguments((L" -loadfile \"" + filePath.wstring() + L"\"").c_str());
shellLinkPtr->SetDescription(filePath.c_str());
shellLinkPtr->SetIconLocation((ydweDirectory / L"bin" / L"logo.ico").c_str(), 0);
});
return SUCCEEDED(hr);
}
示例5: LoadArchive
void CMainWindow::LoadArchive(const boost::filesystem::path& archivePath)
{
try
{
m_playlist.Clear();
m_playlistDiscoveryService.ResetRun();
{
auto archive(CPsfArchive::CreateFromPath(archivePath));
unsigned int archiveId = m_playlist.InsertArchive(archivePath.wstring().c_str());
for(const auto& fileInfo : archive->GetFiles())
{
auto pathToken = CArchivePsfStreamProvider::GetPathTokenFromFilePath(fileInfo.name);
auto fileExtension = pathToken.GetExtension();
if(CPlaylist::IsLoadableExtension(fileExtension))
{
CPlaylist::ITEM newItem;
newItem.path = pathToken.GetWidePath();
newItem.title = newItem.path;
newItem.length = 0;
newItem.archiveId = archiveId;
unsigned int itemId = m_playlist.InsertItem(newItem);
m_playlistDiscoveryService.AddItemInRun(pathToken, archivePath, itemId);
}
}
}
if(m_playlist.GetItemCount() > 0)
{
if(m_repeatMode == PLAYLIST_SHUFFLE)
{
unsigned int itemCount = m_playlist.GetItemCount();
m_randomSeed = GetNextRandomNumber(m_randomSeed);
m_currentPlaylistItem = (m_randomSeed % itemCount);
}
else
{
m_currentPlaylistItem = 0;
}
OnPlaylistItemDblClick(m_currentPlaylistItem);
}
}
catch(const std::exception& except)
{
std::tstring errorString = _T("Couldn't load archive: \r\n\r\n");
errorString += string_cast<std::tstring>(except.what());
MessageBox(m_hWnd, errorString.c_str(), NULL, 16);
}
}
示例6: AbsoluteToLoksimRelativePath
std::wstring AbsoluteToLoksimRelativePath(const boost::filesystem::path& absolutePath, const boost::filesystem::path& l3dDir)
{
wstring upperAbs = boost::algorithm::to_upper_copy(absolutePath.wstring());
wstring upperL3d = boost::algorithm::to_upper_copy(l3dDir.wstring());
boost::algorithm::replace_all(upperAbs, L"/", L"\\");
boost::algorithm::replace_all(upperL3d, L"/", L"\\");
if (upperL3d[upperL3d.size() - 1] != '\\')
{
upperL3d.append(L"\\");
}
if (upperAbs.find(upperL3d) == 0)
{
wstring ret = absolutePath.wstring().substr(upperL3d.length());
if (ret[ret.size() - 1] == '\\')
{
return ret.substr(0, ret.size() - 1);
}
return ret;
}
return absolutePath.wstring();
}
示例7: Impl
/**
* The constructor.
*
* Opens the TIFF using TIFFOpen().
*
* @param filename the filename to open.
* @param mode the file open mode.
*/
Impl(const boost::filesystem::path& filename,
const std::string& mode):
tiff(),
directoryCount(0)
{
Sentry sentry;
#ifdef _MSC_VER
tiff = TIFFOpenW(filename.wstring().c_str(), mode.c_str());
#else
tiff = TIFFOpen(filename.string().c_str(), mode.c_str());
#endif
if (!tiff)
sentry.error();
}
示例8: LoadSingleFile
void CMainWindow::LoadSingleFile(const boost::filesystem::path& filePath)
{
m_playlist.Clear();
m_playlistDiscoveryService.ResetRun();
//Insert a single item in the playlist
{
CPlaylist::ITEM item;
item.path = filePath.wstring();
m_playlist.InsertItem(item);
}
m_currentPlaylistItem = 0;
OnPlaylistItemDblClick(m_currentPlaylistItem);
}
示例9: GetLocalSettingsPfad
// Liefert vollen Pfad zum Local-Settings Ordner des Loksims (LOCAL_APPDATA/Loksim3D)
// Erstellt Verzeichnis falls es nicht existiert
std::wstring GetLocalSettingsPfad()
{
static boost::filesystem::path localAppDataPath;
if (localAppDataPath.empty())
{
std::unique_ptr<wchar_t[]> confpath(new wchar_t[MAX_PATH]);
if (S_OK == SHGetFolderPath(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, confpath.get()))
{
localAppDataPath = boost::filesystem::path(confpath.get()) / L"Loksim3D";
if (!boost::filesystem::exists(localAppDataPath))
{
boost::filesystem::create_directories(localAppDataPath);
}
}
}
return localAppDataPath.wstring();
}
示例10: Save
bool GameScene::Save(boost::filesystem::path file)
{
m_filepath = file;
using namespace engine;
DataStream_File stream;
if(false == stream.OpenStream(file.wstring().c_str(), false))
{
return false;
}
if(false == m_pCore->GetScene()->Serialize(&stream))
{
return false;
}
stream.Close();
return true;
}
示例11: Open
FileIO::Pointer FileIO::Open(
boost::filesystem::path path,
const std::string& open_mode,
std::error_code * error
)
{
if (error)
error->clear();
#if _WIN32
std::wstring wide_open_mode = bytes_to_wide(open_mode);
FILE* file_handle = _wfopen(
path.wstring().c_str(),
wide_open_mode.c_str()
);
#else
FILE* file_handle = fopen(
path.string().c_str(),
open_mode.c_str());
#endif
if (file_handle != nullptr)
{
boost::system::error_code bec;
uint64_t size_hint = boost::filesystem::file_size(path, bec);
if (bec || size_hint == 0)
size_hint = skDefaultBlockSize;
return FileIO::Pointer(new FileIO(
file_handle,
size_hint
));
}
else
{
if ( error != nullptr )
*error = std::error_code(errno, std::system_category());
return FileIO::Pointer();
}
}
示例12: sql
bool
filesystem::create( const boost::filesystem::path& filepath, size_t alloc, size_t page_size )
{
if ( boost::filesystem::exists( filepath ) ) {
boost::system::error_code ec;
if ( ! boost::filesystem::remove( filepath, ec ) ) {
return false;
}
filename_ = filepath.string();
}
db_.reset( new sqlite() );
if ( db_->open( filepath.c_str() ) ) {
filename_ = filepath.string();
adfs::stmt sql( *db_ );
sql.exec( "PRAGMA synchronous = OFF" );
sql.exec( "PRAGMA journal_mode = MEMORY" );
if ( page_size )
sql.exec( ( boost::format( "PRAGMA page_size = %1%" ) % page_size ).str() );
if ( alloc )
internal::fs::prealloc( *db_, alloc );
if ( internal::fs::format( *db_, filepath.wstring(), format_version_ ) ) {
db_->set_fs_format_version( format_version_ );
sql.exec( "PRAGMA FOREIGN_KEYS = ON" );
return true;
}
}
db_.reset();
return false;
}
示例13: recursive_scan
void file_finder::recursive_scan(file_filter::filter_result result, file_filter::filter_argument args, file_filter::filter_engine engine, boost::filesystem::path dir, bool recursive, int current_level) {
if (!args->is_valid_level(current_level)) {
if (args->debug) args->error->report_debug("Level deapth exausted: " + strEx::s::xtos(current_level));
return;
}
WIN32_FIND_DATA wfd;
DWORD fileAttr = GetFileAttributes(dir.wstring().c_str());
if ((fileAttr == INVALID_FILE_ATTRIBUTES)&&(!recursive)) {
args->error->report_error("Invalid file specified: " + dir.string());
} else if (fileAttr == INVALID_FILE_ATTRIBUTES) {
args->error->report_warning("Invalid file specified: " + dir.string());
}
if (args->debug) args->error->report_debug("Input is: " + dir.string() + " / " + strEx::s::xtos(fileAttr));
if (!file_helpers::checks::is_directory(fileAttr)) {
if (args->debug) args->error->report_debug("Found a file won't do recursive scan: " + dir.string());
// It is a file check it an return (don't check recursively)
file_helpers::patterns::pattern_type single_path = file_helpers::patterns::split_path_ex(dir.string());
if (args->debug) args->error->report_debug("Path is: " + single_path.first.string());
HANDLE hFind = FindFirstFile(dir.wstring().c_str(), &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
boost::shared_ptr<file_filter::filter_obj> info = file_filter::filter_obj::get(args->now, wfd, single_path.first);
if (engine)
result->process(info, engine->match(info));
else
result->process(info, true);
FindClose(hFind);
} else {
args->error->report_error("File was NOT found!");
}
return;
}
std::string file_pattern = dir.string() + "\\" + args->pattern;
if (args->debug) args->error->report_debug("File pattern: " + file_pattern);
HANDLE hFind = FindFirstFile(utf8::cvt<std::wstring>(file_pattern).c_str(), &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
if (
file_helpers::checks::is_directory(wfd.dwFileAttributes)
&& ( wcscmp(wfd.cFileName, _T(".")) != 0 || wcscmp(wfd.cFileName, _T("..")) != 0)
)
continue;
boost::shared_ptr<file_filter::filter_obj> info = file_filter::filter_obj::get(args->now, wfd, dir);
if (engine)
result->process(info, engine->match(info));
else
result->process(info, true);
} while (FindNextFile(hFind, &wfd));
FindClose(hFind);
}
std::string dir_pattern = dir.string() + "\\*.*";
if (args->debug) args->error->report_debug("File pattern: " + dir_pattern);
hFind = FindFirstFile(utf8::cvt<std::wstring>(dir_pattern).c_str(), &wfd);
if (hFind != INVALID_HANDLE_VALUE) {
do {
if (file_helpers::checks::is_directory(wfd.dwFileAttributes)) {
if ( (wcscmp(wfd.cFileName, _T(".")) != 0) && (wcscmp(wfd.cFileName, _T("..")) != 0) )
recursive_scan(result, args, engine, dir / wfd.cFileName, true, current_level+1);
}
} while (FindNextFile(hFind, &wfd));
FindClose(hFind);
}
}
示例14: save
void save(Archive& ar, const boost::filesystem::path& p, const unsigned int version)
{
std::wstring str = p.wstring();
ar & BOOST_SERIALIZATION_NVP(str);
}
示例15:
inline start_in_dir_<std::wstring> start_in_dir(const boost::filesystem::path &p)
{
return start_in_dir_<std::wstring>(p.wstring());
}