本文整理汇总了C++中fs::path::wstring方法的典型用法代码示例。如果您正苦于以下问题:C++ path::wstring方法的具体用法?C++ path::wstring怎么用?C++ path::wstring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fs::path
的用法示例。
在下文中一共展示了path::wstring方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Copy
void Copy(fs::path const& from, fs::path const& to) {
acs::CheckFileRead(from);
CreateDirectory(to.parent_path());
acs::CheckDirWrite(to.parent_path());
if (!CopyFile(from.wstring().c_str(), to.wstring().c_str(), false)) {
switch (GetLastError()) {
case ERROR_FILE_NOT_FOUND:
throw FileNotFound(from);
case ERROR_ACCESS_DENIED:
throw fs::WriteDenied("Could not overwrite " + to.string());
default:
throw fs::WriteDenied("Could not copy: " + util::ErrorString(GetLastError()));
}
}
}
示例2: is_picture
bool is_picture( const fs::path& file_path )
{
std::ifstream is( file_path.wstring().c_str(), std::ios::in | std::ios::binary );
if ( !is )
{
return false;
}
unsigned char ch[2] = { 0 };
is.unsetf( std::ios::skipws );
is.read( (char*)ch, 2 );
if ( ch[0] == 0xFF && ch[1] == 0xD8 ) // JPEG
{
return true;
}
else if ( ch[0] == 0x4D && ch[1] == 0x42 ) // BMP
{
return true;
}
return false;
}
示例3: QuickTimePathInvalidExc
::Movie openMovieFromPath( const fs::path &path )
{
::Movie result;
QTNewMoviePropertyElement movieProps[10];
ItemCount moviePropCount = 0;
moviePropCount = openMovieBaseProperties( movieProps );
#if defined( CINDER_MSW )
std::string pathUtf8 = msw::toUtf8String( path.wstring() );
::CFStringRef basePathCF = ::CFStringCreateWithCString( kCFAllocatorDefault, pathUtf8.c_str(), kCFStringEncodingUTF8 );
#else
::CFStringRef basePathCF = ::CFStringCreateWithCString( kCFAllocatorDefault, path.string().c_str(), kCFStringEncodingUTF8 );
#endif
shared_ptr<const __CFString> pathCF = shared_ptr<const __CFString>( basePathCF, ::CFRelease );
// Store the movie properties in the array
movieProps[moviePropCount].propClass = kQTPropertyClass_DataLocation;
movieProps[moviePropCount].propID = kQTDataLocationPropertyID_CFStringNativePath;
movieProps[moviePropCount].propValueSize = sizeof(CFStringRef);
movieProps[moviePropCount].propValueAddress = (void*)&basePathCF;
movieProps[moviePropCount].propStatus = 0;
moviePropCount++;
OSStatus err;
if( (err = ::NewMovieFromProperties( moviePropCount, movieProps, 0, NULL, &result ) ) != noErr ) {
throw QuickTimePathInvalidExc();
}
return result;
}
示例4: remove_empty_directories_recur
bool remove_empty_directories_recur(const fs::path& p, std::vector<fs::path>& dirs)
{
if (!fs::exists(p)) return false;
bool ret = true;
for (fs::directory_iterator i = fs::directory_iterator(p), e = fs::directory_iterator(); i != e; ++i)
{
if (!fs::is_directory(*i))
ret = false;
else
{
if (!remove_empty_directories(*i))
ret = false;
}
}
if (ret)
{
HAL_DEV_MSG(wform(L"Removing directory: %1%") % p.wstring());
dirs.push_back(p);
}
return ret;
}
示例5: CreateFileW
FileLock::FileLock(const fs::path& file)
{
hFile = CreateFileW(file.wstring().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
reason = GetErrorReason();
}
}
示例6: GetFileVersionInfoSize
Version::Version(const fs::path& file) {
#if _WIN32 || _WIN64
DWORD dummy = 0;
DWORD size = GetFileVersionInfoSize(file.wstring().c_str(), &dummy);
if (size > 0) {
LPBYTE point = new BYTE[size];
UINT uLen;
VS_FIXEDFILEINFO *info;
string ver;
GetFileVersionInfo(file.wstring().c_str(),0,size,point);
VerQueryValue(point,L"\\",(LPVOID *)&info,&uLen);
DWORD dwLeftMost = HIWORD(info->dwFileVersionMS);
DWORD dwSecondLeft = LOWORD(info->dwFileVersionMS);
DWORD dwSecondRight = HIWORD(info->dwFileVersionLS);
DWORD dwRightMost = LOWORD(info->dwFileVersionLS);
delete [] point;
verString = to_string(dwLeftMost) + '.' + to_string(dwSecondLeft) + '.' + to_string(dwSecondRight) + '.' + to_string(dwRightMost);
}
#else
// ensure filename has no quote characters in it to avoid command injection attacks
if (string::npos != file.string().find('"')) {
// command mostly borrowed from the gnome-exe-thumbnailer.sh script
// wrestool is part of the icoutils package
string cmd = "wrestool --extract --raw --type=version \"" + file.string() + "\" | tr '\\0, ' '\\t.\\0' | sed 's/\\t\\t/_/g' | tr -c -d '[:print:]' | sed -r 's/.*Version[^0-9]*([0-9]+(\\.[0-9]+)+).*/\\1/'";
FILE *fp = popen(cmd.c_str(), "r");
// read out the version string
static const uint32_t BUFSIZE = 32;
char buf[BUFSIZE];
if (nullptr != fgets(buf, BUFSIZE, fp)) {
verString = string(buf);
}
pclose(fp);
}
#endif
}
示例7: Open
bool reader::Open(const fs::path& zip_file_path)
{
// Use of "Unsafe" function does not look good, but there is no way to do
// this safely on Linux. See file_util.h for details.
zip_file_ = internal::OpenForUnzipping(bee::w2u(zip_file_path.wstring()));
if (!zip_file_)
{
return false;
}
return true;
}
示例8: loadFileStream
IStreamFileRef loadFileStream( const fs::path &path )
{
#if defined( CINDER_MSW )
FILE *f = _wfopen( path.wstring().c_str(), L"rb" );
#else
FILE *f = fopen( path.string().c_str(), "rb" );
#endif
if( f ) {
IStreamFileRef s = IStreamFile::create( f, true );
s->setFileName( path );
return s;
}
else
return IStreamFileRef();
}
示例9: launch
ProcessWithThread Process::launch(const fs::path& app, const wstring& args,
optional<const vector<string>&> env,
optional<const wstring&> cwd,
bool inheritHandles, DWORD creationFlags,
SECURITY_ATTRIBUTES* processAttributes, SECURITY_ATTRIBUTES* threadAttributes,
STARTUPINFOW startupInfo)
{
startupInfo.cb = sizeof(STARTUPINFOW); // needed
PROCESS_INFORMATION pi = {};
wstring commandLine = app.wstring() + L" " + args;
if (!CreateProcessW(app.c_str(), &commandLine[0], processAttributes, threadAttributes, inheritHandles,
creationFlags, nullptr, nullptr, &startupInfo, &pi))
{
DWORD errcode = GetLastError();
BOOST_THROW_EXCEPTION(ex_injection() << e_api_function("CreateProcess") << e_last_error(errcode) << e_file(app));
}
else
return ProcessWithThread(Process(pi.dwProcessId, pi.hProcess), Thread(pi.dwThreadId, pi.hThread));
}
示例10: loadFileStream
IStreamFileRef loadFileStream( const fs::path &path )
{
#if defined( CINDER_MSW )
FILE *f = _wfopen( path.wstring().c_str(), L"rb" );
#else
FILE *f = fopen( path.string().c_str(), "rb" );
#endif
#if defined( CINDER_ANDROID )
if( nullptr == f ) {
throw StreamExc( "(loadFileStream) couldn't open: " + path.string() );
}
#endif
if( f ) {
IStreamFileRef s = IStreamFile::create( f, true );
s->setFileName( path );
return s;
}
else
return IStreamFileRef();
}
示例11: set_system_wallpaper
void set_system_wallpaper( const fs::path& picture )
{
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, const_cast<wchar_t*>( picture.wstring().c_str() ), SPIF_UPDATEINIFILE);
}