这篇教程C++ wchar_to_utf8_cstr函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wchar_to_utf8_cstr函数的典型用法代码示例。如果您正苦于以下问题:C++ wchar_to_utf8_cstr函数的具体用法?C++ wchar_to_utf8_cstr怎么用?C++ wchar_to_utf8_cstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wchar_to_utf8_cstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: move_fileint impl_fuse_context::move_file(LPCWSTR file_name, LPCWSTR new_file_name, BOOL replace_existing, PDOKAN_FILE_INFO dokan_file_info){ if (!ops_.rename || !ops_.getattr) return -EINVAL; std::string name=unixify(wchar_to_utf8_cstr(file_name)); std::string new_name=unixify(wchar_to_utf8_cstr(new_file_name)); struct FUSE_STAT stbuf={0}; if (ops_.getattr(new_name.c_str(),&stbuf)!=-ENOENT) { //Cannot delete directory if ((stbuf.st_mode&S_IFDIR)==0 && ops_.unlink) { if (replace_existing) { CHECKED(ops_.unlink(new_name.c_str())); } else { return -EEXIST; } } } return ops_.rename(name.c_str(),new_name.c_str());}
开发者ID:Thinkscape,项目名称:pfs,代码行数:27,
示例2: unixifyint impl_fuse_context::move_file(LPCWSTR file_name, LPCWSTR new_file_name, BOOL replace_existing, PDOKAN_FILE_INFO dokan_file_info) { if (!ops_.rename || !ops_.getattr) return -EINVAL; std::string name = unixify(wchar_to_utf8_cstr(file_name)); std::string new_name = unixify(wchar_to_utf8_cstr(new_file_name)); struct FUSE_STAT stbuf = {0}; if (ops_.getattr(new_name.c_str(), &stbuf) != -ENOENT) { if (!replace_existing) return -EEXIST; // Cannot delete directory if ((stbuf.st_mode & S_IFDIR) != 0) return -EISDIR; if (!ops_.unlink) return -EINVAL; CHECKED(ops_.unlink(new_name.c_str())); } // this can happen cause DeleteFile in Windows can return success even if // file is still in the file system if (ops_.getattr(new_name.c_str(), &stbuf) != -ENOENT) { return -EEXIST; } CHECKED(ops_.rename(name.c_str(), new_name.c_str())); file_locks.renamed_file(name, new_name); return 0;}
开发者ID:marinkobabic,项目名称:dokany,代码行数:32,
示例3: create_filewin_error impl_fuse_context::create_file(LPCWSTR file_name, DWORD access_mode, DWORD share_mode, DWORD creation_disposition, DWORD flags_and_attributes, PDOKAN_FILE_INFO dokan_file_info){ std::string fname=unixify(wchar_to_utf8_cstr(file_name)); dokan_file_info->Context=0; if (!ops_.getattr) return -EINVAL; struct FUSE_STAT stbuf={0}; //Check if the target file/directory exists if (ops_.getattr(fname.c_str(),&stbuf)<0) { //Nope. if (dokan_file_info->IsDirectory) return -EINVAL; //We can't create directories using CreateFile return do_create_file(file_name, creation_disposition, share_mode, access_mode, dokan_file_info); } else { if (S_ISLNK(stbuf.st_mode)) { //Get link's target CHECKED(resolve_symlink(fname,&fname)); CHECKED(ops_.getattr(fname.c_str(),&stbuf)); } if ((stbuf.st_mode&S_IFDIR)==S_IFDIR) { //Existing directory //TODO: add access control dokan_file_info->IsDirectory=TRUE; return do_open_dir(file_name,dokan_file_info); } else { //Existing file //Check if we'll be able to truncate or delete the opened file //TODO: race condition here? if (creation_disposition==CREATE_ALWAYS) { if (!ops_.unlink) return -EINVAL; CHECKED(ops_.unlink(fname.c_str())); //Delete file //And create it! return do_create_file(file_name,creation_disposition, share_mode, access_mode,dokan_file_info); } else if (creation_disposition==TRUNCATE_EXISTING) { if (!ops_.truncate) return -EINVAL; CHECKED(ops_.truncate(fname.c_str(),0)); } else if (creation_disposition==CREATE_NEW) { return win_error(ERROR_FILE_EXISTS, true); } return do_open_file(file_name, share_mode, access_mode, dokan_file_info); } }}
开发者ID:nightwend,项目名称:dokany,代码行数:60,
示例4: do_create_fileint impl_fuse_context::do_create_file(LPCWSTR FileName, DWORD Disposition, DWORD share_mode, DWORD Flags, PDOKAN_FILE_INFO DokanFileInfo){ std::string fname=unixify(wchar_to_utf8_cstr(FileName)); //Create file? if (Disposition!=CREATE_NEW && Disposition!=CREATE_ALWAYS && Disposition!=OPEN_ALWAYS) return -ENOENT; //No, we're trying to open an existing file! if (!ops_.create) { //Use mknod+open. if (!ops_.mknod || !ops_.open) return -EINVAL; CHECKED(ops_.mknod(fname.c_str(),filemask_,0)); return do_open_file(FileName, share_mode, Flags, DokanFileInfo); } std::auto_ptr<impl_file_handle> file; CHECKED(file_locks.get_file(fname,false,Flags,share_mode,file)); fuse_file_info finfo={0}; finfo.flags=O_CREAT | O_EXCL | convert_flags(Flags); //TODO: these flags should be OK for new files? CHECKED(ops_.create(fname.c_str(),filemask_,&finfo)); DokanFileInfo->Context=reinterpret_cast<ULONG64>(file.release()); return 0;}
开发者ID:nightwend,项目名称:dokany,代码行数:28,
示例5: CheckMountedvoid Drive::Umount(HWND){ // check mounted CheckMounted();// if (GetDriveType(mnt) == DRIVE_NO_ROOT_DIR)// mounted = false; if (!mounted) throw truntime_error(_T("Cannot unmount a not mounted drive")); // unmount fuse_unmount(wchar_to_utf8_cstr(mnt).c_str(), NULL); if (subProcess) { // attach console to allow sending ctrl-c AttachConsole(subProcess->pid); // disable ctrl-c to not exit this process SetConsoleCtrlHandler(HandlerRoutine, TRUE); if (!GenerateConsoleCtrlEvent(CTRL_C_EVENT, subProcess->pid) && !GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, subProcess->pid)) TerminateProcess(subProcess->hProcess, 0); // force exit if (WaitForSingleObject(subProcess->hProcess, 2000) == WAIT_TIMEOUT) TerminateProcess(subProcess->hProcess, 0); // close the console FreeConsole(); SetConsoleCtrlHandler(HandlerRoutine, FALSE); } CheckMounted();}
开发者ID:HirasawaRUS,项目名称:encfs4win,代码行数:33,
示例6: set_file_timeint impl_fuse_context::set_file_time(PCWSTR file_name, const FILETIME* creation_time, const FILETIME* last_access_time, const FILETIME* last_write_time, PDOKAN_FILE_INFO dokan_file_info){ if (!ops_.utimens && !ops_.utime) return -EINVAL; if (!ops_.getattr) return -EINVAL; std::string fname=unixify(wchar_to_utf8_cstr(file_name)); CHECKED(check_and_resolve(&fname)); struct FUSE_STAT st={0}; CHECKED(ops_.getattr(fname.c_str(),&st)); if (ops_.utimens) { struct timespec tv[2]={{0,},}; //TODO: support nanosecond resolution //Access time CHECKED(helper_set_time_struct(last_access_time,st.st_atime,&(tv[0].tv_sec))); //Modification time CHECKED(helper_set_time_struct(last_write_time,st.st_mtime,&(tv[1].tv_sec))); return ops_.utimens(fname.c_str(),tv); } else { struct utimbuf ut={0}; //Access time CHECKED(helper_set_time_struct(last_access_time,st.st_atime,&(ut.actime))); //Modification time CHECKED(helper_set_time_struct(last_write_time,st.st_mtime,&(ut.modtime))); return ops_.utime(fname.c_str(),&ut); }}
开发者ID:Thinkscape,项目名称:pfs,代码行数:34,
示例7: open_directoryint impl_fuse_context::open_directory(LPCWSTR file_name, PDOKAN_FILE_INFO dokan_file_info){ std::string fname=unixify(wchar_to_utf8_cstr(file_name)); if (ops_.opendir) return do_open_dir(file_name,dokan_file_info); //We don't have opendir(), so the most we can do is make sure //that the target is indeed a directory struct FUSE_STAT st={0}; CHECKED(ops_.getattr(fname.c_str(),&st)); if (S_ISLNK(st.st_mode)) { std::string resolved; CHECKED(resolve_symlink(fname,&resolved)); CHECKED(ops_.getattr(resolved.c_str(),&st)); } //Not a directory if ((st.st_mode&S_IFDIR)!=S_IFDIR) return -ENOTDIR; dokan_file_info->Context=(ULONG64)NULL; //Do not want to attach anything return 0; //Use readdir here?}
开发者ID:nightwend,项目名称:dokany,代码行数:26,
示例8: OpenOrCreatestatic voidOpenOrCreate(HWND hwnd){ static bool openAlreadyOpened = false; if (openAlreadyOpened) return; class Unique { public: Unique() { openAlreadyOpened = true; } ~Unique() { openAlreadyOpened = false; } } unique; std::tstring dir = GetExistingDirectory(hwnd, _T("Select a folder which contains or will contain encrypted data."), _T("Select Crypt Folder")); if (dir.empty()) return; // if directory is already configured add and try to mount boost::shared_ptr<EncFSConfig> config(new EncFSConfig); if (readConfig(slashTerminate(wchar_to_utf8_cstr(dir.c_str())), config) != Config_None) { char drive = SelectFreeDrive(hwnd); if (drive) { Drives::drive_t dr(Drives::Add(dir, drive)); if (dr) dr->Mount(hwnd); } return; } // TODO check directory is empty, warning if continue // "You are initializing a crypted directory with a no-empty directory. Is this expected?" OptionsData data; data.rootDir = dir; if (DialogBoxParam(hInst, (LPCTSTR) IDD_OPTIONS, hwnd, (DLGPROC) OptionsDlgProc, (LPARAM) &data) != IDOK) return; // add configuration and add new drive createConfig(slashTerminate(wchar_to_utf8_cstr(dir.c_str())), data.paranoia, false, wchar_to_utf8_cstr(data.password).c_str(), true); Drives::drive_t dr(Drives::Add(dir, data.drive)); if (dr) dr->Mount(hwnd);}
开发者ID:rustyx,项目名称:encfs4win,代码行数:45,
示例9: do_open_dirint impl_fuse_context::do_open_dir(LPCWSTR FileName, PDOKAN_FILE_INFO DokanFileInfo){ if (ops_.opendir) { fuse_file_info finfo={0}; std::string fname=unixify(wchar_to_utf8_cstr(FileName)); CHECKED(ops_.opendir(fname.c_str(),&finfo)); DokanFileInfo->Context=reinterpret_cast<ULONG64>(new impl_file_handle(fname,true,&finfo)); return 0; } DokanFileInfo->Context=0; return 0;}
开发者ID:Thinkscape,项目名称:pfs,代码行数:15,
示例10: utf8_to_wchar_bufint impl_fuse_context::walk_directory(void *buf, const char *name, const struct FUSE_STAT *stbuf, FUSE_OFF_T off){ walk_data *wd=(walk_data*)buf; WIN32_FIND_DATAW find_data={0}; utf8_to_wchar_buf(name,find_data.cFileName,MAX_PATH); // fix name if wrong encoding if (!find_data.cFileName[0]) { struct FUSE_STAT stbuf={0}; utf8_to_wchar_buf_old(name,find_data.cFileName,MAX_PATH); std::string new_name = wchar_to_utf8_cstr(find_data.cFileName); if (wd->ctx->ops_.getattr && wd->ctx->ops_.rename && new_name.length() && wd->ctx->ops_.getattr(new_name.c_str(),&stbuf) == -ENOENT) wd->ctx->ops_.rename(name, new_name.c_str()); } memset(find_data.cAlternateFileName, 0, sizeof(find_data.cAlternateFileName)); struct FUSE_STAT stat={0}; if (stbuf!=NULL) stat=*stbuf; else { //No stat buffer - use 'getattr'. //TODO: fill directory params here!!! if (strcmp(name,".")==0 || strcmp(name,"..")==0) //Special entries stat.st_mode|=S_IFDIR; else CHECKED(wd->ctx->ops_.getattr((wd->dirname+name).c_str(),&stat)); } if (S_ISLNK(stat.st_mode)) { std::string resolved; CHECKED(wd->ctx->resolve_symlink(wd->dirname+name,&resolved)); CHECKED(wd->ctx->ops_.getattr(resolved.c_str(),&stat)); } convertStatlikeBuf(&stat,name,&find_data); uint32_t attrs = 0xFFFFFFFFu; if (wd->ctx->ops_.win_get_attributes) attrs = wd->ctx->ops_.win_get_attributes((wd->dirname+name).c_str()); if (attrs != 0xFFFFFFFFu) find_data.dwFileAttributes = attrs; return wd->delegate(&find_data,wd->DokanFileInfo);}
开发者ID:nightwend,项目名称:dokany,代码行数:48,
示例11: do_open_fileint impl_fuse_context::do_open_file(LPCWSTR FileName, DWORD Flags, PDOKAN_FILE_INFO DokanFileInfo){ if (!ops_.open) return -EINVAL; std::string fname=unixify(wchar_to_utf8_cstr(FileName)); CHECKED(check_and_resolve(&fname)); fuse_file_info finfo={0}; //if ((ShareMode & FILE_SHARE_READ) || (ShareMode & FILE_SHARE_DELETE)) //TODO: add sharing support? finfo.flags=convert_flags(Flags); CHECKED(ops_.open(fname.c_str(),&finfo)); DokanFileInfo->Context=reinterpret_cast<ULONG64>(new impl_file_handle(fname,false,&finfo)); return 0;}
开发者ID:Thinkscape,项目名称:pfs,代码行数:16,
示例12: CHECKEDint impl_fuse_context::set_end_of_file(LPCWSTR file_name, LONGLONG byte_offset, PDOKAN_FILE_INFO dokan_file_info) { FUSE_OFF_T off; CHECKED(cast_from_longlong(byte_offset, &off)); std::string fname = unixify(wchar_to_utf8_cstr(file_name)); CHECKED(check_and_resolve(&fname)); impl_file_handle *hndl = reinterpret_cast<impl_file_handle *>(dokan_file_info->Context); if (hndl && ops_.ftruncate) { fuse_file_info finfo(hndl->make_finfo()); return ops_.ftruncate(hndl->get_name().c_str(), off, &finfo); } if (!ops_.truncate) return -EINVAL; return ops_.truncate(fname.c_str(), off);}
开发者ID:marinkobabic,项目名称:dokany,代码行数:18,
示例13: do_open_fileint impl_fuse_context::do_open_file(LPCWSTR FileName, DWORD share_mode, DWORD Flags, PDOKAN_FILE_INFO DokanFileInfo){ if (!ops_.open) return -EINVAL; std::string fname=unixify(wchar_to_utf8_cstr(FileName)); CHECKED(check_and_resolve(&fname)); std::auto_ptr<impl_file_handle> file; CHECKED(file_locks.get_file(fname,false,Flags,share_mode,file)); fuse_file_info finfo={0}; finfo.flags=convert_flags(Flags); CHECKED(ops_.open(fname.c_str(),&finfo)); file->set_finfo(finfo); DokanFileInfo->Context=reinterpret_cast<ULONG64>(file.release()); return 0;}
开发者ID:nightwend,项目名称:dokany,代码行数:19,
示例14: do_open_dirint impl_fuse_context::do_open_dir(LPCWSTR FileName, PDOKAN_FILE_INFO DokanFileInfo){ if (ops_.opendir) { std::string fname=unixify(wchar_to_utf8_cstr(FileName)); std::auto_ptr<impl_file_handle> file; // TODO access_mode CHECKED(file_locks.get_file(fname,true,0,FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,file)); fuse_file_info finfo={0}; CHECKED(ops_.opendir(fname.c_str(),&finfo)); file->set_finfo(finfo); DokanFileInfo->Context=reinterpret_cast<ULONG64>(file.release()); return 0; } DokanFileInfo->Context=0; return 0;}
开发者ID:nightwend,项目名称:dokany,代码行数:20,
示例15: whilevoid Drive::Mount(HWND hwnd){ // check drive empty or require a new drive while (GetDriveType(mnt) != DRIVE_NO_ROOT_DIR) { char drive = SelectFreeDrive(hwnd); if (!drive) return; _stprintf(mnt, _T("%c://"), drive); Save(); } // check directory existence if (!isDirectory(wchar_to_utf8_cstr(dir.c_str()).c_str())) { if (YesNo(hwnd, _T("Directory does not exists. Remove from list?"))) Drives::Delete(shared_from_this()); return; } // TODO check configuration still exists ?? ... no can cause recursion problem // search if executable is present TCHAR executable[MAX_PATH]; if (!SearchPath(NULL, _T("encfs.exe"), NULL, LENGTH(executable), executable, NULL)) throw truntime_error(_T("Unable to find encfs.exe file")); // ask a password to mount TCHAR pass[128+2]; if (!GetPassword(hwnd, pass, LENGTH(pass)-2)) return; _tcscat(pass, _T("/r/n")); // mount using a sort of popen TCHAR cmd[2048]; _sntprintf(cmd, LENGTH(cmd), _T("/"%s/" -S /"%s/" %c:"), executable, dir.c_str(), mnt[0]); boost::shared_ptr<SubProcessInformations> proc(new SubProcessInformations); proc->creationFlags = CREATE_NEW_PROCESS_GROUP|CREATE_NO_WINDOW; if (!CreateSubProcess(cmd, proc.get())) { DWORD err = GetLastError(); memset(pass, 0, sizeof(pass)); _sntprintf(cmd, LENGTH(cmd), _T("Error: %s (%u)"), proc->errorPart, (unsigned) err); throw truntime_error(cmd); } subProcess = proc; // send the password std::string pwd = wchar_to_utf8_cstr(pass); DWORD written; WriteFile(proc->hIn, pwd.c_str(), pwd.length(), &written, NULL); CloseHandle(proc->hIn); // close input so sub process does not any more proc->hIn = NULL; memset(pass, 0, sizeof(pass)); memset((char*) pwd.c_str(), 0, pwd.length()); mounted = false; // wait for mount, read error and give feedback for (unsigned n = 0; n < 5*10; ++n) { // drive appeared if (GetDriveType(mnt) != DRIVE_NO_ROOT_DIR) { if (Drives::autoShow) Show(hwnd); break; } // process terminated DWORD readed; char output[2048]; switch (WaitForSingleObject(subProcess->hProcess, 200)) { case WAIT_OBJECT_0: case WAIT_ABANDONED: if (ReadFile(proc->hOut, output, sizeof(output)-1, &readed, NULL)) { output[readed] = 0; utf8_to_wchar_buf(output, cmd, LENGTH(cmd)); } else { _stprintf(cmd, _T("Unknown error mounting drive %c:"), mnt[0]); } subProcess.reset(); throw truntime_error(cmd); } } if (subProcess) mounted = true; Save(); // save for resume}
开发者ID:HirasawaRUS,项目名称:encfs4win,代码行数:84,
注:本文中的wchar_to_utf8_cstr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wclrtobot函数代码示例 C++ wborder函数代码示例 |