本文整理汇总了C++中wxFileName::GetDirs方法的典型用法代码示例。如果您正苦于以下问题:C++ wxFileName::GetDirs方法的具体用法?C++ wxFileName::GetDirs怎么用?C++ wxFileName::GetDirs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxFileName
的用法示例。
在下文中一共展示了wxFileName::GetDirs方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DirNameCmp
/**
* comparator function that compares 2 filenames by using the full name
* only (wxFileName::GetDirs().Last())
*/
static bool DirNameCmp(const wxFileName& a, const wxFileName& b) {
if (a.GetDirCount() == 0) {
return true;
}
if (b.GetDirCount() == 0) {
return false;
}
wxString aName = a.GetDirs().Last();
wxString bName = b.GetDirs().Last();
return aName.compare(bName) < 0;
}
示例2: IsSuffixOfPath
// Checks whether 'suffix' could be a suffix of 'path' and therefore represents
// the same path. This is used to check whether a relative path could represent
// the same path as absolute path. For instance, for
// suffix = sdk/globals.cpp
// path = /home/user/codeblocks/trunk/src/sdk/globals.cpp
// it returns true. The function expects that 'path' is normalized and compares
// 'path' with 'suffix' starting from the end of the path. When it reaches .. in
// 'suffix' it gives up (there is no way to check relative filename names
// exactly) and if the path compared so far is identical, it returns true
bool IsSuffixOfPath(wxFileName const & suffix, wxFileName const & path)
{
if (path.GetFullName() != suffix.GetFullName())
{
return false;
}
wxArrayString suffixDirArray = suffix.GetDirs();
wxArrayString pathDirArray = path.GetDirs();
int j = pathDirArray.GetCount() - 1;
for (int i = suffixDirArray.GetCount() - 1; i >= 0; i--)
{
if (suffixDirArray[i] == _T(".") || suffixDirArray[i] == _T(""))
{
// skip paths like /./././ and ////
continue;
}
if (j < 0)
{
// suffix has more directories than path - cannot represent the same path
return false;
}
if (suffixDirArray[i] == _T(".."))
{
// suffix contains ".." - from now on we cannot precisely determine
// whether suffix and path match - we assume that they do
return true;
}
else if (suffixDirArray[i] != pathDirArray[j])
{
// the corresponding directories of the two paths differ
return false;
}
j--;
}
if (suffix.IsAbsolute() && (j >= 0 || suffix.GetVolume() != path.GetVolume()))
{
return false;
}
// 'suffix' is a suffix of 'path'
return true;
}
示例3: WinPathToCygwin
wxString eDocumentPath::WinPathToCygwin(const wxFileName& path) {
wxASSERT(path.IsOk() && path.IsAbsolute());
#ifndef __WXMSW__
return path.GetFullPath();
#else
wxString fullpath = path.GetFullPath();
// Check if we have a foward-slash unc path; cygwin can handle these directly.
if (fullpath.StartsWith(wxT("//"))) {
return fullpath;
}
// Check if we have a backslash unc path; convert to forward slash and pass on.
if (fullpath.StartsWith(wxT("\\\\"))) {
fullpath.Replace(wxT("\\"), wxT("/"));
return fullpath;
}
// Convert C:\... to /cygdrive/c/...
wxString unixPath = eDocumentPath::s_cygdrivePrefix + path.GetVolume().Lower();
// Convert slashs in path segments
const wxArrayString& dirs = path.GetDirs();
for (unsigned int i = 0; i < dirs.GetCount(); ++i) {
unixPath += wxT('/') + dirs[i];
}
// Add the filename, if there is one
if (path.HasName()) unixPath += wxT('/') + path.GetFullName();
return unixPath;
#endif
}
示例4: CreateDirectoryPath
void Path::CreateDirectoryPath(const wxFileName &path){
if(!path.IsDir() || path.DirExists())
return;
wxArrayString folders = path.GetDirs();
wxString workingpath;
//We need to do things differently with a unc path
if(path.GetFullPath().Left(2) == "\\\\")
workingpath = "\\\\?\\UNC\\" + path.GetVolume() + "\\";
else
workingpath = "\\\\?\\" + path.GetVolume() + wxFileName::GetVolumeSeparator() + wxFILE_SEP_PATH;
for(unsigned int i = 0; i < folders.GetCount(); i++){
workingpath = workingpath + folders.Item(i) + wxFILE_SEP_PATH;
#ifdef __WXMSW__
if(!wxDirExists(workingpath) && !CreateDirectory(workingpath.fn_str(), NULL)){
#else
if(!wxDirExists(workingpath) && !wxMkdir(workingpath)){
#endif
wxLogError(_("Could not create") + " " + workingpath);
}
}
}
wxFileName Path::Normalise(const wxFileName &filename){
wxString path = Path::Normalise(filename.GetFullPath());
return wxFileName(path);
}
示例5: OnMenuExport
void BundlePane::OnMenuExport(wxCommandEvent& WXUNUSED(event)) {
const wxTreeItemId selItem = m_bundleTree->GetSelection();
if (!selItem.IsOk()) return;
// Get the item name
const BundleItemData* data = (BundleItemData*)m_bundleTree->GetItemData(selItem);
wxString name;
if (data->IsBundle()) {
const wxFileName bundlePath = m_plistHandler.GetBundlePath(data->m_bundleId);
name = bundlePath.GetDirs().Last();
}
else {
const wxFileName bundlePath = m_plistHandler.GetBundleItemPath(data->m_type, data->m_bundleId, data->m_itemId);
name = bundlePath.GetFullName();
}
// Get destination path from user
const wxString msg = data->IsBundle() ? _("Export Bundle as..") : _("Export Bundle Item as");
wxFileDialog dlg(this, msg, wxEmptyString, name, wxFileSelectorDefaultWildcardStr, wxFD_SAVE);
if (dlg.ShowModal() != wxID_OK) return;
const wxString path = dlg.GetPath();
if (path.empty()) return;
// Export the item
if (data->IsBundle()) {
wxFileName dstPath;
dstPath.AssignDir(path);
m_plistHandler.ExportBundle(dstPath, data->m_bundleId);
}
else m_plistHandler.ExportBundleItem(path, data->m_type, data->m_bundleId, data->m_itemId);
}
示例6: normalizeAbsolutePaths
static bool normalizeAbsolutePaths( const wxFileName& aPathA,
const wxFileName& aPathB,
wxString* aResultPath )
{
wxCHECK_MSG( aPathA.IsAbsolute(), false, aPathA.GetPath() + " is not an absolute path." );
wxCHECK_MSG( aPathB.IsAbsolute(), false, aPathB.GetPath() + " is not an absolute path." );
if( aPathA.GetPath() == aPathB.GetPath() )
return true;
if( ( aPathA.GetDirCount() > aPathB.GetDirCount() )
|| ( aPathA.HasVolume() && !aPathB.HasVolume() )
|| ( !aPathA.HasVolume() && aPathB.HasVolume() )
|| ( ( aPathA.HasVolume() && aPathB.HasVolume() )
&& ( aPathA.GetVolume() != aPathB.GetVolume() ) ) )
return false;
wxArrayString aDirs = aPathA.GetDirs();
wxArrayString bDirs = aPathB.GetDirs();
size_t i = 0;
while( i < aDirs.GetCount() )
{
if( aDirs[i] != bDirs[i] )
return false;
i++;
}
if( aResultPath )
{
while( i < bDirs.GetCount() )
{
*aResultPath += bDirs[i] + wxT( "/" );
i++;
}
}
return true;
}
示例7: GetDocDir
/*
$(prefix)/share/doc/mmex
*/
const wxFileName mmex::GetDocDir()
{
static wxFileName fname;
if (!fname.IsOk())
{
fname = GetSharedDir();
const wxArrayString &dirs = fname.GetDirs();
if (dirs.Last().Lower() == GetAppName())
fname.RemoveLastDir(); // mmex folder
fname.AppendDir("doc");
fname.AppendDir(GetAppName());
}
return fname;
}
示例8: WinPathToCygwin
wxString WinPathToCygwin(const wxFileName& path) { // static
wxASSERT(path.IsOk() && path.IsAbsolute());
// Drive
wxString unixPath = wxT("/cygdrive/");
unixPath += path.GetVolume().Lower();
// Dirs
const wxArrayString& dirs = path.GetDirs();
for (unsigned int i = 0; i < dirs.GetCount(); ++i) {
unixPath += wxT('/') + dirs[i];
}
// Filename
if (path.HasName()) {
unixPath += wxT('/') + path.GetFullName();
}
return unixPath;
}
示例9: GetIsFileNameValid
bool NewFileDialog::GetIsFileNameValid(const wxFileName& fileName) const
{
if (!fileName.IsOk())
{
return false;
}
// Check if the file name has illegal characters in it.
wxString forbidden = fileName.GetForbiddenChars();
const wxArrayString dirs = fileName.GetDirs();
for (unsigned int i = 0; i < dirs.Count(); ++i)
{
for (unsigned int j = 0; j < dirs[i].Length(); ++j)
{
if (forbidden.Find(dirs[i][j]) != wxNOT_FOUND)
{
return false;
}
}
}
wxString fullName = fileName.GetFullName();
for (unsigned int j = 0; j < fullName.Length(); ++j)
{
if (forbidden.Find(fullName[j]) != wxNOT_FOUND)
{
return false;
}
}
return true;
}
示例10: AddDir
void AddFilesDialog::AddDir(const wxString& path, const wxFileName& base_offset)
{
if (::wxDirExists(path))
{
if (this->progress)
this->progress->Update(0, "Adding " + path);
::wxSafeYield();
wxDir d(path);
if (d.IsOpened() && d.HasFiles())
{
wxString file;
bool cont = d.GetFirst(&file);
while (cont)
{
wxFileName fn(path, file);
if (fn.DirExists())
{
wxFileName base(base_offset);
base.AppendDir(file);
this->AddDir(fn.GetFullPath(), base);
} else if (fn.FileExists()) {
this->files.push_back(new ManifestCreationFile(base_offset.GetDirs(), fn));
}
cont = d.GetNext(&file);
}
}
} else {
// do nothing
}
}
示例11: GetName
wxString GetName() const { return m_file_name.GetDirs().Last(); }