コード例 #1
0
ファイル: hd_libdlg.cpp プロジェクト: philm001/Omni-FEM
void hdCLibDlg::MouseModify()
{
	if(m_dragTargetList!=NULL)
	{
		if(!IsFolder(m_dragTargetList)){
			int k=(int) m_mylist.GetItemData(m_dragTargetList);
			ModifyMaterial(k);
			m_mylist.SetItemText(m_dragTargetList,LibProps[k].BlockName);
		}
	}

	if(m_dragTargetTree!=NULL)
	{
		if(!IsFolder(m_dragTargetTree)){
			int k=(int) m_mytree.GetItemData(m_dragTargetTree);
			ModifyMaterial(k);
			m_mytree.SetItemText(m_dragTargetTree,LibProps[k].BlockName);
		}
		else{
			CLibFolderInfo dlg;
			
			int k=(int) m_mytree.GetItemData(m_dragTargetTree);
			dlg.m_foldername  =FoldProps[k].FolderName;
			dlg.m_folderurl   =FoldProps[k].FolderURL;
			dlg.m_foldervendor=FoldProps[k].FolderVendor;
			if (dlg.DoModal()==IDOK)
			{
				m_mytree.SetItemText(m_dragTargetTree,dlg.m_foldername);
				FoldProps[k].FolderName  =dlg.m_foldername;
				FoldProps[k].FolderURL   =dlg.m_folderurl;
				FoldProps[k].FolderVendor=dlg.m_foldervendor;
			}
		}
	}
}
コード例 #2
0
ファイル: FolderLib.cpp プロジェクト: OLR-xray/OLR-3.0
void CFolderHelper::DragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State, bool &Accept)
{
	TElTree* tv = dynamic_cast<TElTree*>(Sender); VERIFY(Sender);
	TElTreeItem* tgt;

    for (ELVecIt it=drag_items.begin(); it!=drag_items.end(); it++){
        TElTreeItem* src=*it;
        TSTItemPart IP;
        int HCol;
        if (!src) Accept = false;
        else{
            tgt = tv->GetItemAt(X, Y, IP, HCol);
            if (tgt){
                if (IsFolder(src)){
                    bool b = true;
                    for (TElTreeItem* itm=tgt->Parent; itm; itm=itm->Parent) if (itm==src){b=false; break;}
                    if (IsFolder(tgt)){
                        Accept = b&&(tgt!=src)&&(src->Parent!=tgt);
                    }else if (IsObject(tgt)){
                        Accept = b&&(src!=tgt->Parent)&&(tgt!=src)&&(tgt->Parent!=src->Parent);
                    }
                }else if (IsObject(src)){
                    if (IsFolder(tgt)){
                        Accept = (tgt!=src)&&(src->Parent!=tgt);
                    }else if (IsObject(tgt)){
                        Accept = (tgt!=src)&&(src->Parent!=tgt->Parent);
                    }
                }
            }else Accept = !!src->Parent;
        }
        if (false==Accept) return;
    }
}
コード例 #3
0
void TorrentObject::MimeType(BMimeType& mime)
{
	mime.SetTo(B_DIRECTORY_MIME_TYPE);
	
	if( !IsFolder() && !IsMagnet() )
		BMimeType::GuessMimeType(Info()->files[0].name, &mime);
}
コード例 #4
0
ファイル: NseBaseItem.cpp プロジェクト: TaChiBaNaIChiKa/repo1
/**
 * Create the item as a new folder in the virtual file-system.
 */
HRESULT CNseBaseItem::_DoNewFolder(VFS_MENUCOMMAND& Cmd, UINT uLabelRes)
{
   ATLASSERT(IsFolder());
   // The new folder's label
   CComBSTR bstrLabel;
   bstrLabel.LoadString(uLabelRes);
   // Create a new folder.
   // TODO: Support FOF_RENAMEONCOLLISION flag.
   CComPtr<IFileOperation> spFO;
   HR( ::SHCreateFileOperation(Cmd.hWnd
	   , FOF_SILENT | FOF_NOCONFIRMATION | FOFX_NOSKIPJUNCTIONS 
	   , &spFO) );
   CComPtr<IShellItem> spTargetFolder;
   HR( ::SHCreateItemFromIDList(m_pFolder->m_pidlMonitor, IID_PPV_ARGS(&spTargetFolder)) );

   spFO->NewItem(spTargetFolder, FILE_ATTRIBUTE_DIRECTORY, bstrLabel, NULL, m_pFolder);
   HR( spFO->PerformOperations() );

   // HarryWu, 2014.2.6
   // if do NOT go into edit mode, whatever. 
   // ----------------------------------
   //// Go into edit-mode for new item
   // HR( _AddSelectEdit(Cmd.punkSite, bstrLabel) );

   // We handled this operation successfully for all items in selection
   return NSE_S_ALL_DONE;
}
コード例 #5
0
ファイル: DockItem.cpp プロジェクト: HaikuArchives/LaunchPad
void
DockItem::GetGenericIcon( void )
{
	if ( IsFolder() ) {
		BMimeType type;
		type.SetType( "application/x-vnd.Be-directory" );
		type.GetIcon( mLargeIcon, B_LARGE_ICON );
		type.GetIcon( mSmallIcon, B_MINI_ICON );
	} else {
		app_info appInfo;
		BFile appFile;
		BAppFileInfo appFileInfo;
		be_app->GetAppInfo( &appInfo );
		appFile.SetTo( &appInfo.ref, B_READ_WRITE );
		appFileInfo.SetTo( &appFile );
		appFileInfo.GetIconForType( "application/x-be-executable", mLargeIcon, B_LARGE_ICON );
		appFileInfo.GetIconForType( "application/x-be-executable", mSmallIcon, B_MINI_ICON );
		/*
		BMimeType appType;
		appType.SetType( "application/x-vnd.HK-LaunchPad" );
		appType.GetIcon( mLargeIcon, B_LARGE_ICON );
		appType.GetIcon( mSmallIcon, B_MINI_ICON );
		*/
	}
}
コード例 #6
0
ファイル: Table.cpp プロジェクト: agazso/keyspace
Table::Table(Database* database, const char *name, int pageSize) :
database(database)
{
	DbTxn *txnid = NULL;
	const char *filename = name;
	const char *dbname = NULL;
	DBTYPE type = DB_BTREE;
	u_int32_t flags = DB_CREATE | DB_AUTO_COMMIT |
	DB_NOMMAP 
#ifdef DB_READ_UNCOMMITTED
	| DB_READ_UNCOMMITTED
#endif
	;

	int mode = 0;
	
	db = new Db(database->env, 0);
	if (pageSize != 0)
		db->set_pagesize(pageSize);
		
	Log_Trace();
	if (db->open(txnid, filename, dbname, type, flags, mode) != 0)
	{
		db->close(0);
		if (IsFolder(filename))
		{
			STOP_FAIL(rprintf(
					  "Could not create database file '%s' "
					  "because a folder '%s' exists",
					  filename, filename), 1);
		}
		STOP_FAIL("Could not open database", 1);
	}
	Log_Trace();
}
コード例 #7
0
ファイル: hd_libdlg.cpp プロジェクト: philm001/Omni-FEM
void hdCLibDlg::AddNewProperty()
{
	HTREEITEM hParent,hResult;

	if(m_dragTargetList!=NULL)
	{
		hParent = m_mylist.GetParentItem(m_dragTargetList);
        if( hParent != NULL )
			hResult=m_mylist.InsertItem("New Material", 2, 2, ModelParent, m_dragTargetList);
		else
			hResult=m_mylist.InsertItem("New Material", 2, 2, ModelParent, TVI_LAST );

		CMaterialProp MProp;
		LibProps.Add(MProp);
		m_mylist.SetItemData(hResult,LibProps.GetUpperBound());
	}

	if(m_dragTargetTree!=NULL)
	{
		if(IsFolder(m_dragTargetTree)) hParent=m_dragTargetTree;
		else hParent = m_mytree.GetParentItem(m_dragTargetTree);
        if( hParent != NULL )
			hResult=m_mytree.InsertItem("New Material", 2, 2, hParent, m_dragTargetTree);
		else
			hResult=m_mytree.InsertItem("New Material", 2, 2, LibParent, TVI_LAST );

		CMaterialProp MProp;
		LibProps.Add(MProp);
		m_mytree.SetItemData(hResult,LibProps.GetUpperBound());
	}
}
コード例 #8
0
BString TorrentObject::DownloadFolder() const
{
	if( IsFolder() )
		return BString().SetToFormat("%s/%s", tr_torrentGetDownloadDir(fTorrentHandle), Name().String());
		
	return tr_torrentGetDownloadDir(fTorrentHandle);
}
コード例 #9
0
ファイル: FileSystem.cpp プロジェクト: Knockd/Vlpp
		WString FilePath::GetRelativePathFor(const FilePath& _filePath)
		{
			if (fullPath.Length()==0 || _filePath.fullPath.Length()==0 || fullPath[0] != _filePath.fullPath[0])
			{
				return _filePath.fullPath;
			}
#if defined VCZH_MSVC
			wchar_t buffer[MAX_PATH + 1] = { 0 };
			PathRelativePathTo(
				buffer,
				fullPath.Buffer(),
				(IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0),
				_filePath.fullPath.Buffer(),
				(_filePath.IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0)
				);
			return buffer;
#elif defined VCZH_GCC
			collections::List<WString> srcComponents, tgtComponents, resultComponents;
			GetPathComponents(IsFolder() ? fullPath : GetFolder().GetFullPath(), srcComponents);
			GetPathComponents(_filePath.fullPath, tgtComponents);

			int minLength = srcComponents.Count() <= tgtComponents.Count() ? srcComponents.Count() : tgtComponents.Count();
			int lastCommonComponent = 0;
			for(int i = 0; i < minLength; i++)
			{
				if(srcComponents[i] == tgtComponents[i])
				{
					lastCommonComponent = i;
				}
				else
					break;
			}

			for(int i = lastCommonComponent + 1; i < srcComponents.Count(); i++)
			{
				resultComponents.Add(L"..");
			}

			for(int i = lastCommonComponent + 1; i < tgtComponents.Count(); i++)
			{
				resultComponents.Add(tgtComponents[i]);
			}

			return ComponentsToPath(resultComponents);
#endif
		}
コード例 #10
0
	shared_ptr< vector<char> > CMabiFile::GetContents()
	{
		if (IsFolder())
		{
			throw logic_error("folder is not support this method.");
		}
		return m_contentProvider->GetContents();
	}
コード例 #11
0
	void CMabiFile::WriteToFile(const wstring& path)
	{
		if (IsFolder())
		{
			throw logic_error("folder is not support this method.");
		}
		m_contentProvider->WriteToFile(path);
	}
コード例 #12
0
	FILETIME CMabiFile::GetFileTime(int index) const
	{
		if (IsFolder())
		{
			throw logic_error("folder is not support this method.");
		}
		return m_contentProvider->GetFileTime(index);
	}
コード例 #13
0
	unsigned long CMabiFile::GetVersion() const
	{
		if (IsFolder())
		{
			throw logic_error("folder is not support this method.");
		}
		return m_contentProvider->GetVersion();
	}
コード例 #14
0
ファイル: UppWspc.cpp プロジェクト: AbdelghaniDr/mirror
void UppList::Paint(Draw& w, const Rect& r, const Value& q, Color ink, Color paper, dword style) const
{
	FileList::File file = ValueTo<FileList::File>(q);
	if(GetFileName(file.name) == "$.tpp" && IsFolder(file.name))
		file.name = GetFileName(GetFileFolder(file.name)) + " templates";
	if(file.name == ConfigFile("global.defs"))
		file.name = "Fixed macros";
	FileList::Paint(w, r, RawToValue(file), ink, paper, style);
}
コード例 #15
0
NrpText OpFileSystem::GetExtension( const NrpText& pathTo )
{
	assert( !IsFolder( pathTo ) );
	int index = pathTo.findLast( L'.' );
	if( index >= 0 )
	    return pathTo.subString( index, 0xff );

	return "";
}
コード例 #16
0
ファイル: File.cpp プロジェクト: 1285done/cuberite
bool cFile::Delete(const AString & a_Path)
{
	if (IsFolder(a_Path))
	{
		return DeleteFolder(a_Path);
	}
	else
	{
		return DeleteFile(a_Path);
	}
}
コード例 #17
0
void FolderTree::DoExpand(HTREEITEM hItem)
{
	FolderTreeItemInfo* pItem = (FolderTreeItemInfo*) GetItemData(hItem);

	//Reset the drive node if the drive is empty or the media has changed
	if (IsMediaValid(pItem->m_sFQPath))
	{
		//Delete the item if the path is no longer valid
		if (IsFolder(pItem->m_sFQPath))
		{
			//Add the new items to the tree if it does not have any child items
			//already
			if (!GetChildItem(hItem))
				DisplayPath(pItem->m_sFQPath, hItem);
		}
		else if (hItem == m_hMyComputerRoot)
		{
			//Display an hour glass as this may take some time
			//CWaitCursor wait;

			//Enumerate the local drive letters
			auto shared = sp->getViewItems(sp->curProfile);
			DisplayDrives(m_hMyComputerRoot, FALSE, shared);
		}
		else if ((hItem == m_hNetworkRoot) || (pItem->m_pNetResource))
		{
			//Display an hour glass as this may take some time
			//CWaitCursor wait;

			//Enumerate the network resources
			EnumNetwork(hItem);
		}
		else
		{
			//Before we delete it see if we are the only child item
			HTREEITEM hParent = GetParentItem(hItem);

			//Delete the item
			DeleteItem(hItem);

			//Remove all the child items from the parent
			SetHasPlusButton(hParent, false);
		}
	}
	else
	{
		//Display an hour glass as this may take some time
		//CWaitCursor wait;

		//Collapse the drive node and remove all the child items from it
		Expand(hItem, TVE_COLLAPSE);
		DeleteChildren(hItem, true);
	}
}
コード例 #18
0
ファイル: FolderLib.cpp プロジェクト: OLR-xray/OLR-3.0
void CFolderHelper::CreateNewFolder(TElTree* tv, bool bEditAfterCreate)
{
	AnsiString folder;
    AnsiString start_folder;
    MakeName(tv->Selected,0,start_folder,true);
    TElTreeItem* parent = tv->Selected?(IsFolder(tv->Selected)?tv->Selected:tv->Selected->Parent):0;
    GenerateFolderName(tv,parent,folder);
    folder = start_folder+folder;
	TElTreeItem* node = AppendFolder(tv,folder.c_str(),true);
    if (tv->Selected) tv->Selected->Expand(false);
    if (bEditAfterCreate) tv->EditItem(node,-1);
}
コード例 #19
0
ファイル: UppWspc.cpp プロジェクト: AbdelghaniDr/mirror
void WorkspaceWork::LoadActualPackage()
{
	Time utime = FileGetTime(ConfigFile("version"));
	filelist.Clear();
	fileindex.Clear();
	bool open = true;
	Time tm = GetSysTime();
	for(int i = 0; i < actual.file.GetCount(); i++) {
		Package::File& f = actual.file[i];
		if(f.separator) {
			open = closed.Find(Sepfo(actualpackage, f)) < 0;
			filelist.Add(f, open ? IdeImg::SeparatorClose() : IdeImg::SeparatorOpen(),
			             ListFont().Bold(), open ? SColorMark : SColorText, true, 0, Null);
			fileindex.Add(i);
		}
		else
		if(open) {
			Color uln = Null;
			String p = SourcePath(GetActivePackage(), f);
			if(showtime) {
				FindFile ff(p);
				if(ff) {
					Time ftm = Time(ff.GetLastWriteTime());
					if(ftm > utime) {
						int64 t = tm - ftm;
						if(t < 24 * 3600)
							uln = SColorMark;
						else
						if(t < 32 * 24 * 3600)
							uln = SColorDisabled;
					}
				}
			}
			Image m = IdeFileImage(f, f.optimize_speed, false, f.pch);
			if(GetFileExt(p) == ".tpp" && IsFolder(p)) {
				if(FileExists(AppendFileName(p, "all.i")))
					m = TopicImg::IGroup();
				else
					m = TopicImg::Group();
			}
		#ifdef PLATFORM_WIN32
			p = ToLower(p);
		#endif
			if(errorfiles.Find(p) >= 0) {
				m = ImageOverRed(m);
				uln = LtRed;
			}
			filelist.Add(f, m, ListFont(), SColorText, false, 0,
			             Null, SColorMark, Null, Null, Null, uln);
			fileindex.Add(i);
		}
	}
}
コード例 #20
0
ファイル: vfs.cpp プロジェクト: 4v4t4r/Hack-Night
DWORD VFS::GetDirectoryListing(const char *pszVirtual, DWORD dwIsNLST, listing_type &listing)
// Fills a map class with lines comprising an FTP-style directory listing.
// If dwIsNLST is non-zero, will return filenames only.
{
	char szLine[512];
	const char *pszMonthAbbr[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
	LPVOID hFind;
	WIN32_FIND_DATA w32fd;
	SYSTEMTIME stCutoff, stFile;

	if (IsFolder(pszVirtual)) {
		string str;
		ResolveRelative(pszVirtual, "*", str);
		hFind = FindFirstFile(str.c_str(), &w32fd);
	}
	else {
		hFind = FindFirstFile(pszVirtual, &w32fd);
	}
	if (hFind) {
		GetSystemTime(&stCutoff);
		stCutoff.wYear--;
		do {
			if (!strcmp(w32fd.cFileName, ".") || !strcmp(w32fd.cFileName, "..")) continue;
			FileTimeToSystemTime(&w32fd.ftLastWriteTime, &stFile);
			if (dwIsNLST) {
				strcpy_s(szLine, w32fd.cFileName);
				if (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
					strcat_s(szLine, "/");
				}
			} else {
				wsprintf(szLine, "%c--------- 1 ftp ftp %10u %s %2u ", (w32fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? 'd' : '-', w32fd.nFileSizeLow, pszMonthAbbr[stFile.wMonth-1], stFile.wDay);
				if ((stFile.wYear > stCutoff.wYear) || ((stFile.wYear == stCutoff.wYear) && ((stFile.wMonth > stCutoff.wMonth) || ((stFile.wMonth == stCutoff.wMonth) && (stFile.wDay > stCutoff.wDay))))) {
					wsprintf(szLine + strlen(szLine), "%.2u:%.2u ", stFile.wHour, stFile.wMinute);
				} else {
					wsprintf(szLine + strlen(szLine), "%5u ", stFile.wYear);
				}
				strcat_s(szLine, w32fd.cFileName);
			}
			strcat_s(szLine,"\r\n");
			listing_type::iterator it = listing.find(w32fd.cFileName);
			if (it != listing.end()) {
				it->second = szLine;
			}
			else {
				listing.insert(std::make_pair(w32fd.cFileName, szLine));
			}
		} while (FindNextFile(hFind, &w32fd));
		FindClose(hFind);
		return 1;
	} else {
		return 0;
	}
}
コード例 #21
0
ファイル: hd_libdlg.cpp プロジェクト: philm001/Omni-FEM
void hdCLibDlg::OnRclickMylist(NMHDR* pNMHDR, LRESULT* pResult) 
{
		CMenu* pMenu = NULL;
		try
		{
			pMenu = new CMenu;
		}
		catch(...)
		{
			pMenu = NULL;
		}
		ASSERT(pMenu);
		
		POINT point;
		GetCursorPos(&point);
		CPoint ptList(point);
		UINT uHitTest = TVHT_ONITEM;
		GetDesktopWindow()->MapWindowPoints( &m_mylist, &ptList, 1 );
		m_dragTargetList = m_mylist.HitTest( ptList, &uHitTest );
		m_dragTargetTree = NULL;

		if(m_dragTargetList==NULL) m_dragTargetList=ModelParent;

		VERIFY(pMenu->CreatePopupMenu());
		if (m_dragTargetList!=ModelParent)
			VERIFY(pMenu->AppendMenu(MF_STRING, ID_EDIT_CUT, "Delete Selected"));
		else
			VERIFY(pMenu->AppendMenu(MF_STRING, ID_EDIT_FIND, "Import Materials"));
		VERIFY(pMenu->AppendMenu(MF_STRING, ID_EDIT_COPY, "Add New Material"));

		if(m_dragTargetList!=NULL)
		{
			if(!IsFolder(m_dragTargetList))
				VERIFY(pMenu->AppendMenu(MF_STRING, ID_EDIT_REPLACE, "Modify Material"));
		}

		pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,point.x,point.y,this);

		try
		{
			delete pMenu;
		}
		catch(...)
		{
			ASSERT(FALSE);
			TRACE("hdCLibDlg::OnRclickMylist failed to destroy menu resource\n");
			pMenu = FALSE;
		}

	*pResult = 0;
}
コード例 #22
0
ファイル: FileSystem.cpp プロジェクト: mazip1990/FaceUI
	bool Folder::Create(bool recursively)const
	{
		if (recursively)
		{
			auto folder = filePath_.GetFolder();
			if (folder.IsFile()) return false;
			if (folder.IsFolder()) return Create(false);
			return Folder(folder).Create(true) && Create(false);
		}
		else
		{
			return CreateDirectory(filePath_.GetFullPath().Buffer(), NULL) != 0;
		}
	}
コード例 #23
0
wxString SFTPAttribute::GetTypeAsString() const
{
    if ( IsSpecial() ) {
        return "Special";
    } else if ( IsFolder() ) {
        return "Folder";
    } else if ( IsSymlink() ) {
        return "Symlink";
    } else if ( IsFile() ) {
        return "File";
    } else {
        return "Unknown";
    }
}
コード例 #24
0
ファイル: FolderLib.cpp プロジェクト: OLR-xray/OLR-3.0
BOOL CFolderHelper::RemoveItem(TElTree* tv, TElTreeItem* pNode, TOnItemRemove OnRemoveItem, TOnItemAfterRemove OnAfterRemoveItem)
{
	bool bRes = false;
    R_ASSERT(OnRemoveItem);
    if (pNode){
		tv->IsUpdating = true;
	    TElTreeItem* pSelNode = pNode->GetPrevSibling();
	    if (!pSelNode) pSelNode = pNode->GetNextSibling();
		AnsiString full_name;
    	if (IsFolder(pNode)){
//			if (mrYes==MessageDlg("Delete selected folder?", mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0))
            {
                bRes = true;
		        for (TElTreeItem* item=pNode->GetFirstChild(); item&&(item->Level>pNode->Level); item=item->GetNext()){
                    MakeName(item,0,full_name,false);
                	if (IsObject(item)){
                    	bool res		= true;
                    	OnRemoveItem(full_name.c_str(),TYPE_OBJECT,res);
                    	if (!res) bRes	= FALSE;
                    }
                }
                if (bRes){
                    MakeName(pNode,0,full_name,true);
                    bool res			= true;
                	OnRemoveItem(full_name.c_str(),TYPE_FOLDER,res);
                	pNode->Delete();
                    if (!OnAfterRemoveItem.empty()) OnAfterRemoveItem();
                }
        	}
        }
    	if (IsObject(pNode)){
//			if (mrYes==MessageDlg("Delete selected item?", mtConfirmation, TMsgDlgButtons() << mbYes << mbNo, 0))
            {
				MakeName	(pNode,0,full_name,false);
                OnRemoveItem(full_name.c_str(),TYPE_OBJECT,bRes);
	            if (bRes){
                	pNode->Delete();
                    if (!OnAfterRemoveItem.empty()) OnAfterRemoveItem();
                }
        	}
        }
        if (bRes) tv->Selected = pSelNode;
        tv->IsUpdating 	= false;
        tv->SetFocus();
    }else{
		Msg				("#At first select item.");
    }
    return bRes;
}
コード例 #25
0
ファイル: UppWspc.cpp プロジェクト: AbdelghaniDr/mirror
void WorkspaceWork::DelFile()
{
	if(!filelist.IsCursor() || filelist[fileindex[filelist.GetCursor()]].isdir) return;
	String file = GetActiveFilePath();
	if(IsFolder(file)) {
		if(!PromptYesNo("Remove the topic group and discard ALL topics?")) return;
		RemoveFile();
		DeleteFolderDeep(file);
	}
	else {
		if(!PromptYesNo("Remove the file from package and discard it ?")) return;
		RemoveFile();
		::DeleteFile(file);
	}
}
コード例 #26
0
ファイル: FileSystem.cpp プロジェクト: mazip1990/FaceUI
	WString FilePath::GetRelativePathFor(const FilePath& _filePath)
	{
		if (_fullPath.Length()==0 || _filePath._fullPath.Length()==0 || _fullPath[0] != _filePath._fullPath[0])
		{
			return _filePath._fullPath;
		}
		wchar_t buffer[MAX_PATH + 1] = { 0 };
		PathRelativePathTo(
			buffer,
			_fullPath.Buffer(),
			(IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0),
			_filePath._fullPath.Buffer(),
			(_filePath.IsFolder() ? FILE_ATTRIBUTE_DIRECTORY : 0)
			);
		return buffer;
	}
コード例 #27
0
ファイル: hd_libdlg.cpp プロジェクト: philm001/Omni-FEM
HTREEITEM hdCLibDlg::CopyItemToModel(HTREEITEM hItem, HTREEITEM hTarget)
{
	HTREEITEM hResult,hParent,hChild;
	
	if (IsFolder(hItem))
	{
		hChild=m_mytree.GetChildItem(hItem) ;
		hParent=hTarget;
		while (hChild!=NULL)
		{
			hParent=CopyItemToModel(hChild,hParent) ;
			hChild = m_mytree.GetNextSiblingItem(hChild);
		}
		hResult=hParent;
	}
	else{	

        CString szLabel;
		int ItemData;
		if(!bDragFromLibrary)
		{
			szLabel = m_mylist.GetItemText(hItem);
			ItemData = (int) m_mylist.GetItemData(hItem);
		}
		else{
			szLabel = m_mytree.GetItemText(hItem);
			ItemData = (int) m_mytree.GetItemData(hItem);
		}

		if(bDragFromLibrary)
		{
			CMaterialProp MProp=LibProps[ItemData];
			LibProps.Add(MProp);
			int NewItemData=(int) LibProps.GetUpperBound();
			ItemData=NewItemData;
		}

		hParent = m_mylist.GetParentItem( hTarget );
        if( hParent != NULL )
			hResult=m_mylist.InsertItem( szLabel, 2, 2, ModelParent, hTarget);
		else
			hResult=m_mylist.InsertItem( szLabel, 2, 2, ModelParent, TVI_LAST );
		m_mylist.SetItemData(hResult,ItemData);
	}
	
	return hResult;
}
コード例 #28
0
ファイル: NseBaseItem.cpp プロジェクト: TaChiBaNaIChiKa/repo1
/**
 * Add new item, select it and go into rename-mode.
 * This is a helper function for the NewFolder operation. After creating the folder
 * in the virtual file-system, we add the item temporarily to the Shell view and
 * go right into edit-mode, allowing the user to rename the item.
 */
HRESULT CNseBaseItem::_AddSelectEdit(IUnknown * punkSite, LPCWSTR pszLabel, DWORD dwFlags /*= SVSI_DESELECTOTHERS | SVSI_ENSUREVISIBLE | SVSI_SELECT | SVSI_EDIT*/)
{
   ATLASSERT(IsFolder());
   // Validate label
   if( pszLabel == NULL ) pszLabel = L"";
   // Get to the IFolderView2 interface
   CComQIPtr<IServiceProvider> spService = punkSite;
   if( spService == NULL ) return E_NOINTERFACE;
   CComPtr<IFolderView2> spFV2;
   HR( spService->QueryService(SID_SFolderView, IID_PPV_ARGS(&spFV2)) );
   // Tell View to add item and rename it at once
   CNseItemPtr spNewItem;
   HR( GetChild(pszLabel, SHGDN_FOREDITING, &spNewItem) );
   PCUITEMID_CHILD pidlNewItem = spNewItem->GetITEMID();
   ShellFolderView_AddObject(m_pFolder->m_hwndOwner, ::ILCloneChild(pidlNewItem));
   POINT pt = { 0, 0 };
   HR( spFV2->SelectAndPositionItems(1, &pidlNewItem, &pt, dwFlags) );
   return S_OK;
}
コード例 #29
0
ファイル: hd_libdlg.cpp プロジェクト: philm001/Omni-FEM
void hdCLibDlg::CopyItemToDisk(HTREEITEM hItem, FILE *fp)
{
	HTREEITEM hChild;
	int i =(int) m_mytree.GetItemData(hItem);
	int j;
		
	if (IsFolder(hItem))
	{
		fprintf(fp,"<BeginFolder>\n");
		fprintf(fp,"<FolderName> = \"%s\"\n",FoldProps[i].FolderName);
		if(FoldProps[i].FolderURL!="")
			fprintf(fp,"<FolderURL> = \"%s\"\n",FoldProps[i].FolderURL);
		if(FoldProps[i].FolderVendor!="")
			fprintf(fp,"<FolderVendor> = \"%s\"\n",FoldProps[i].FolderVendor);

		hChild=m_mytree.GetChildItem(hItem) ;
		while (hChild!=NULL)
		{
			CopyItemToDisk(hChild,fp) ;
			hChild = m_mytree.GetNextSiblingItem(hChild) ;
		}

		fprintf(fp,"<EndFolder>\n");
	}
	else{
		fprintf(fp,"<BeginBlock>\n");
		fprintf(fp,"<BlockName> = \"%s\"\n",LibProps[i].BlockName);
		fprintf(fp,"<Kx> = %.17g\n",LibProps[i].Kx);
		fprintf(fp,"<Ky> = %.17g\n",LibProps[i].Ky);
		fprintf(fp,"<Kt> = %.17g\n",LibProps[i].Kt);
		fprintf(fp,"<qv> = %.17g\n",LibProps[i].qv);
		if (LibProps[i].npts>0)
		{ 
			fprintf(fp,"    <TKPoints> = %i\n",LibProps[i].npts);
		    for (j=0;j<LibProps[i].npts;j++)
			{
				fprintf(fp,"      %.17g	%.17g\n",LibProps[i].Kn[j].re, LibProps[i].Kn[j].im);
			}
		}
		fprintf(fp,"<EndBlock>\n\n");
	}
}
コード例 #30
0
ファイル: main.c プロジェクト: Airr/osxutils
static OSErr PrintLabelName (FSRef *fileRef)
{
	static char	labelNames[8][8] = { "None", "Red", "Orange", "Yellow", "Green", "Blue", "Purple", "Gray" };
	FSSpec		fileSpec;
    FInfo 		finderInfo;
	DInfo       dInfo;
	OSErr		err = noErr;
	int			labelNum = 0;

	/* retrieve filespec from file ref */
    err = FSGetCatalogInfo (fileRef, NULL, NULL, NULL, &fileSpec, NULL);
    if (err != noErr) 
    {
        fprintf(stderr, "FSGetCatalogInfo(): Error %d getting file spec from file reference\n", err);
        return err;
    }
	
	if (IsFolder(fileRef))
	{
		err = FSGetDInfo (fileRef, &dInfo);
		if (err != noErr)
		{
			fprintf(stderr, "FSpGetFInfo(): Error %d getting file Finder Directory Info from file spec\n", err);
			return err;
		}
		labelNum = GetLabelNumber(dInfo.frFlags);
	}
	else
	{
		err = FSGetFInfo (fileRef, &finderInfo);
		if (err != noErr)
		{
			fprintf(stderr, "FSpGetFInfo(): Error %d getting file Finder File Info from file spec\n", err);
			return err;
		}
		labelNum = GetLabelNumber(finderInfo.fdFlags);
	}
	
	printf("%s\n", (char *)&labelNames[labelNum]);
	
	return noErr;
}