コード例 #1
0
ファイル: CBrowser.cpp プロジェクト: eriser/koblo_software-1
void CBrowser::Update()
{
	UpdateFolder(&mItemRoot);

	// Get number of lines
	tint32 iLineCount = 0;
	GetItemCount(mItemRoot.SubItems, iLineCount);

	// We now know the amount of lines, and can set the size
	SSize SizeNew(GetSize());
	SizeNew.iCY = miMarginTop + (iLineCount * miSpaceBetweenItems);
	if (SizeNew.iCY < mSizeMin.iCY) {
		SizeNew.iCY = mSizeMin.iCY;
	}
	if (SizeNew != GetSize()) {
		SetSize(SizeNew);

		SScrollPos ScrollPos;
		mpScrollPane->GetScrollPos(ScrollPos);
		ScrollPos.AreaSize = SizeNew;
		mpScrollBar->SetScrollPos(ScrollPos, true);
	}

	Redraw();
}
コード例 #2
0
ファイル: CpDialog.cpp プロジェクト: jimmccurdy/ArchiveGit
DWORD CCpDialog::CheckForUiUpdates(CString& strAppRootFolder)
{
	if (strAppRootFolder.IsEmpty())
		return 0;

	CString strUpdatesFolder = strAppRootFolder + String(IDS_UIUPDATES_FOLDER);

	// Be sure the update folder and sub-folders exist
	bool bCreated = false;
	bCreated = !!::CreateDirectory(strUpdatesFolder, NULL);
	bCreated = !!::CreateDirectory(strUpdatesFolder + "cp\\", NULL);
	bCreated = !!::CreateDirectory(strUpdatesFolder + "images\\", NULL);

	// Update the app folder from the updates folder
	DWORD dwCount = UpdateFolder(strUpdatesFolder, strAppRootFolder);

	// Update the updates folders from the app folder
	dwCount += UpdateFolder(strAppRootFolder, strUpdatesFolder, false/*bIncludeSubFolders*/);
	dwCount += UpdateFolder(strAppRootFolder + "cp\\", strUpdatesFolder + "cp\\");
	dwCount += UpdateFolder(strAppRootFolder + "images\\", strUpdatesFolder + "images\\");

	return dwCount;
}
コード例 #3
0
ファイル: SpecialFolder.cpp プロジェクト: fin-alice/bb4nt
//===========================================================================
// SpecialFolder
//===========================================================================
SpecialFolder::SpecialFolder(const TCHAR *pszTitle, const struct pidl_node *pidl_list, const TCHAR  *optional_command)
    : Menu(pszTitle)
{
	m_MenuID    = MENU_ID_SF;   // ID
	m_pidl_list = NULL;         // the list of pidl
	m_notify    = 0;
	// create a copy of the SpecialFolderItem's pidl-list
	m_pidl_list = copy_pidl_list(pidl_list);
	m_pszExtra  = new_str(optional_command);
	// attach a copy of the (first) pidl to the TitleItem (for
	// "shift - right - click on title" - context menu.
	if (m_pidl_list) m_pMenuItems->m_pidl = duplicateIDlist(m_pidl_list->v);
	// fill menu
	UpdateFolder();
}
コード例 #4
0
ファイル: FoldersService.cpp プロジェクト: jurda23/homeis
void FoldersService::render_PUT(const http_request& req, http_response** res)
{
	if (req.get_user()=="a" && req.get_pass()=="a")
	{
		string strid = req.get_arg("id");
		string content = req.get_content();

		if (UpdateFolder(strid,content))
		{
			*res = new http_string_response("", 200, "application/json");
			return;
		}
	}
	else
	{
		string message = "Autentication error";
		*res = new http_string_response(message.c_str(), 401, "application/json");
		return;
	}

	*res = new http_string_response("", 403, "application/json");

}
コード例 #5
0
ファイル: CBrowser.cpp プロジェクト: eriser/koblo_software-1
void CBrowser::UpdateFolder(SItem* pFolder)
{
	SItem* pFolderTmp = new SItem;

	tint32 iItemCount = giBrowserMaxItemsPerFolder;
	IBrowser::SItem* pItems = new IBrowser::SItem[iItemCount];

	std::string sPathName(pFolder->sPathName);
	if (sPathName != std::string("")) {
#ifdef WIN32
		sPathName += std::string("\\");
#endif
#ifdef _Mac
		sPathName += std::string(":");
#endif
	}
	mpCallback->Browse((tchar*)(sPathName.c_str()), pItems, iItemCount);

	// Convert to internal structure
	tint32 iItem;
	for (iItem = 0; iItem < iItemCount; iItem++) {
		CBrowser::SItem* pItemInternal = new CBrowser::SItem();

		strcpy((char*)(pItemInternal->pszName), (char*)(pItems[iItem].pszName));
		pItemInternal->bFolder = pItems[iItem].bFolder;

		pItemInternal->sNameModified = std::string((char*)(pItemInternal->pszName));
		pItemInternal->sPathName = pFolder->sPathName;
#ifdef WIN32
		pItemInternal->sPathName += std::string("\\");
#endif
#ifdef _Mac
		pItemInternal->sPathName += std::string(":");
#endif
		pItemInternal->sPathName += std::string((char*)(pItemInternal->pszName));
		pItemInternal->bFolderIsOpen = false;

		pFolderTmp->SubItems.push_back(pItemInternal);

		if (pItemInternal->bFolder) {
			// Check if folder previously was open
		}
	}

	delete[] pItems;

	// Go through the old items, deleting the ones missing, and updating the sub folders
	// These are the items we wish to delete from list. We'll do it in the end, so we don't mess up the iterator
	std::list<SItem*> DeleteList;
	tint32 iNrOfItems = pFolder->SubItems.size();
	std::list<SItem*>::iterator it = pFolder->SubItems.begin();
	for (iItem = 0; iItem < iNrOfItems; iItem++, it++) {
		SItem* pItem = *it;
		std::string sName = std::string((char*)pItem->pszName);

		// See if we can find this item in the new list
		std::list<SItem*>::iterator it2 = pFolderTmp->SubItems.begin();
		bool bFoundIt = false;
		for (; it2 != pFolderTmp->SubItems.end(); it2++) {
			SItem* pItemNew = *it2;
			std::string sNameNew = std::string((char*)pItemNew->pszName);
			if (sNameNew.compare(sName) == 0) {
				// The names match
				bFoundIt = true;
				// Update the new list
				delete pItemNew;
				pFolderTmp->SubItems.erase(it2);
				break;
			}
		}
		if (bFoundIt) {
			if (pItem->bFolder) {
				if (pItem->bFolderIsOpen) {
					UpdateFolder(pItem);
				}
			}
		}
		else {
			// We didn't find it, so put it in list of items to delete
			DeleteList.push_back(pItem);
		}
	}

	// Delete the items, which needs to be deleted
	it = DeleteList.begin();
	for (; it != DeleteList.end(); it++) {
		SItem* pItem = *it;
		delete pItem;
		pFolder->SubItems.remove(pItem);
	}

	// All remaining items in the new list needs to be put in the old list
	it = pFolderTmp->SubItems.begin();
	for (; it != pFolderTmp->SubItems.end(); it++) {
		SItem* pItem = *it;
		pFolder->SubItems.push_back(pItem);
	}
	// Clear the new list, since we don't want the items to be deleted (they've been transfered to the old list)
	pFolderTmp->SubItems.clear();

	delete pFolderTmp;
}
コード例 #6
0
ファイル: CpDialog.cpp プロジェクト: jimmccurdy/ArchiveGit
DWORD CCpDialog::UpdateFolder(LPCSTR strSrcFolder, LPCSTR strDstFolder, bool bIncludeSubFolders)
{
	CString strSrcPath = strSrcFolder + CString("*.*");

	DWORD dwFileCount = 0;
	CFileFind FileFind;
	BOOL bFound = FileFind.FindFile(strSrcPath);
	while (bFound)
	{
		bFound = FileFind.FindNextFile();
		if (FileFind.IsDots())
			continue;

		CString strSrcFilePath = FileFind.GetFilePath();
		CString strSrcFileName = FileFind.GetFileName();

		if (FileFind.IsDirectory())
		{
			if (!bIncludeSubFolders)
				continue;

			CString strNewDstFolder = CString(strDstFolder) + strSrcFileName + "\\";
			bool bCreated = !!::CreateDirectory(strNewDstFolder, NULL);
			if (bCreated)
				dwFileCount++;

			CString strNewSrcFolder = strSrcFilePath + "\\";
			dwFileCount += UpdateFolder(strNewSrcFolder, strNewDstFolder);
			continue;
		}

		FILETIME SrcCreationTime;
		FILETIME SrcAccessedTime;
		FILETIME SrcModfiedTime;
		FileFind.GetCreationTime(&SrcCreationTime);
		FileFind.GetLastAccessTime(&SrcAccessedTime);
		FileFind.GetLastWriteTime(&SrcModfiedTime);

		CString strDstFilePath = CString(strDstFolder) + strSrcFileName;
		if (FileExists(strDstFilePath))
		{
			FILETIME DstCreationTime;
			FILETIME DstAccessedTime;
			FILETIME DstModfiedTime;
			bool bOK = GetFileTimes(strDstFilePath, DstCreationTime, DstAccessedTime, DstModfiedTime);
			if (CFileTime(SrcModfiedTime) <= CFileTime(DstModfiedTime))
				continue;

			DWORD dwFileAttributes = ::GetFileAttributes(strDstFilePath);
			if (dwFileAttributes && FILE_ATTRIBUTE_READONLY)
				::SetFileAttributes(strDstFilePath, dwFileAttributes & ~FILE_ATTRIBUTE_READONLY);
		}

		bool bCopied = !!::CopyFile(strSrcFilePath, strDstFilePath, false/*bFailIfExists*/);
		if (bCopied)
		{
			dwFileCount++;
			SetFileTimes(strDstFilePath, SrcCreationTime, SrcAccessedTime, SrcModfiedTime);
		}
	}
	
	FileFind.Close();
	return dwFileCount;
}