コード例 #1
0
ファイル: AvatarDlg.cpp プロジェクト: kmdtukl/miranda-ng
int FillAvatarListFromFolder(HWND list, MCONTACT hContact)
{
	int max_pos = 0;
	TCHAR dir[MAX_PATH], path[MAX_PATH];
	WIN32_FIND_DATA finddata;

	GetContactFolder(dir, hContact);
	mir_sntprintf(path, _countof(path), _T("%s\\*.lnk"), dir);

	HANDLE hFind = FindFirstFile(path, &finddata);
	if (hFind == INVALID_HANDLE_VALUE)
		return 0;

	do
	{
		if (finddata.cFileName[0] != '.')
		{
			TCHAR lnk[MAX_PATH];
			mir_sntprintf(lnk, _countof(lnk), _T("%s\\%s"), dir, finddata.cFileName);
			if (ResolveShortcut(lnk, path))
				max_pos = AddFileToList(path,lnk,finddata.cFileName,list);
		}
	}
		while(FindNextFile(hFind, &finddata));
	FindClose(hFind);
	SendMessage(list, LB_SETCURSEL, max_pos, 0); // Set to first item
	return 0;
}
コード例 #2
0
ファイル: GGeneral.cpp プロジェクト: FEI17N/Lgi
////////////////////////////////////////////////////////////////
// Local helper functions
bool _lgi_check_file(char *Path)
{
	if (Path)
	{
		if (FileExists(Path))
		{
			// file is there
			return true;
		}
		else
		{
			// shortcut?
			char *e = Path + strlen(Path);
			strcpy(e, ".lnk");
			if (FileExists(Path))
			{
				// resolve shortcut
				char Link[256];
				if (ResolveShortcut(Path, Link, sizeof(Link)))
				{
					// check destination of link
					if (FileExists(Link))
					{
						strcpy(Path, Link);
						return true;
					}
				}
			}
			*e = 0;
		}
	}

	return false;
}
コード例 #3
0
//
// FindURLFromLocalFile
//
// we are looking for a URL and couldn't find it, try again with looking for 
// a local file. If we have one, it may either be a normal file or an internet shortcut.
// In both cases, however, we can get a URL (it will be a file:// url in the
// local file case).
//
bool
nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, void** outData, PRUint32* outDataLen )
{
  bool dataFound = false;

  nsresult loadResult = GetNativeDataOffClipboard(inDataObject, inIndex, GetFormat(kFileMime), nullptr, outData, outDataLen);
  if ( NS_SUCCEEDED(loadResult) && *outData ) {
    // we have a file path in |data|. Is it an internet shortcut or a normal file?
    const nsDependentString filepath(static_cast<PRUnichar*>(*outData));
    nsCOMPtr<nsIFile> file;
    nsresult rv = NS_NewLocalFile(filepath, true, getter_AddRefs(file));
    if (NS_FAILED(rv)) {
      nsMemory::Free(*outData);
      return dataFound;
    }

    if ( IsInternetShortcut(filepath) ) {
      nsMemory::Free(*outData);
      nsCAutoString url;
      ResolveShortcut( file, url );
      if ( !url.IsEmpty() ) {
        // convert it to unicode and pass it out
        nsDependentString urlString(UTF8ToNewUnicode(url));
        // the internal mozilla URL format, text/x-moz-url, contains
        // URL\ntitle.  We can guess the title from the file's name.
        nsAutoString title;
        file->GetLeafName(title);
        // We rely on IsInternetShortcut check that file has a .url extension.
        title.SetLength(title.Length() - 4);
        if (title.IsEmpty())
          title = urlString;
        *outData = ToNewUnicode(urlString + NS_LITERAL_STRING("\n") + title);
        *outDataLen = NS_strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);

        dataFound = true;
      }
    }
    else {
      // we have a normal file, use some Necko objects to get our file path
      nsCAutoString urlSpec;
      NS_GetURLSpecFromFile(file, urlSpec);

      // convert it to unicode and pass it out
      nsMemory::Free(*outData);
      *outData = UTF8ToNewUnicode(urlSpec);
      *outDataLen = NS_strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);
      dataFound = true;
    } // else regular file
  }

  return dataFound;
} // FindURLFromLocalFile
コード例 #4
0
ファイル: OpenSave.c プロジェクト: akavel/neatpad
//
//	How to process WM_DROPFILES
//
void HandleDropFiles(HWND hwnd, HDROP hDrop)
{
	TCHAR buf[MAX_PATH];
	
	if(DragQueryFile(hDrop, 0, buf, MAX_PATH))
	{
		TCHAR tmp[MAX_PATH];
		
		if(ResolveShortcut(buf, tmp, MAX_PATH))
			lstrcpy(buf,tmp);

		NeatpadOpenFile(hwnd, buf);
	}
	
	DragFinish(hDrop);
}
コード例 #5
0
ファイル: OpenSave.c プロジェクト: avplayer/avdbg
//
//	How to process WM_DROPFILES
//
void HandleDropFiles(HWND hwnd, HDROP hDrop)
{
	TCHAR buf[MAX_PATH];
	DROPFILES *df = (DROPFILES *)hDrop;
	
	if(DragQueryFile(hDrop, 0, buf, MAX_PATH))
	{
		TCHAR tmp[MAX_PATH];
		
		if(ResolveShortcut(buf, tmp, MAX_PATH))
			lstrcpy(buf,tmp);

		HexeditOpenFile(hwnd, buf, HVOF_DEFAULT);
	}
	
	DragFinish(hDrop);
}
コード例 #6
0
ファイル: nsClipboard.cpp プロジェクト: fortunto2/celtx
//
// FindURLFromLocalFile
//
// we are looking for a URL and couldn't find it, try again with looking for 
// a local file. If we have one, it may either be a normal file or an internet shortcut.
// In both cases, however, we can get a URL (it will be a file:// url in the
// local file case).
//
PRBool
nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, void** outData, PRUint32* outDataLen )
{
  PRBool dataFound = PR_FALSE;

  nsresult loadResult = GetNativeDataOffClipboard(inDataObject, inIndex, GetFormat(kFileMime), outData, outDataLen);
  if ( NS_SUCCEEDED(loadResult) && *outData ) {
    // we have a file path in |data|. Is it an internet shortcut or a normal file?
    const nsDependentString filepath(static_cast<PRUnichar*>(*outData));
    nsCOMPtr<nsILocalFile> file;
    nsresult rv = NS_NewLocalFile(filepath, PR_TRUE, getter_AddRefs(file));
    if (NS_FAILED(rv))
      return dataFound;

    if ( IsInternetShortcut(filepath) ) {
      nsCAutoString url;
      ResolveShortcut( file, url );
      if ( !url.IsEmpty() ) {
        // convert it to unicode and pass it out
        nsMemory::Free(*outData);
        *outData = UTF8ToNewUnicode(url);
        *outDataLen = nsCRT::strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);

        dataFound = PR_TRUE;
      }
    }
    else {
      // we have a normal file, use some Necko objects to get our file path
      nsCAutoString urlSpec;
      NS_GetURLSpecFromFile(file, urlSpec);

      // convert it to unicode and pass it out
      nsMemory::Free(*outData);
      *outData = UTF8ToNewUnicode(urlSpec);
      *outDataLen = nsCRT::strlen(static_cast<PRUnichar*>(*outData)) * sizeof(PRUnichar);
      dataFound = PR_TRUE;
    } // else regular file
  }

  return dataFound;
} // FindURLFromLocalFile
コード例 #7
0
ファイル: GDocApp.cpp プロジェクト: FEI17N/Lgi
bool GDocApp<OptionsFmt>::_OpenFile(char *File, bool ReadOnly)
{
	bool Status = false;
	if (SetDirty(false))
	{
		char RealPath[256];
		if (ResolveShortcut(File, RealPath, sizeof(RealPath)))
		{
			File = RealPath;
		}

		Status = GMru::_OpenFile(File, ReadOnly);
		if (Status)
		{
			d->Dirty = false;
			SetCurFile(File);
		}
	}

	return Status;
}
コード例 #8
0
ファイル: GDocApp.cpp プロジェクト: FEI17N/Lgi
bool GDocApp<OptionsFmt>::_SaveFile(char *File)
{
	char RealPath[256];
	if (ResolveShortcut(File, RealPath, sizeof(RealPath)))
	{
		File = RealPath;
	}
	else
	{
		strcpy_s(RealPath, sizeof(RealPath), File);
	}

	bool Status = GMru::_SaveFile(RealPath);
	if (Status)
	{
		d->Dirty = false;
		SetCurFile(RealPath);
		OnDirty(d->Dirty);
	}

	return Status;
}
コード例 #9
0
ファイル: bookmark_edit_dlg.cpp プロジェクト: 3rdexp/fxfile
void BookmarkEditDlg::OnQuickLaunch(void) 
{
    const xpr_tchar_t *sMsg = gApp.loadString(XPR_STRING_LITERAL("popup.bookmark_edit.msg.question_quick_launch"));
    xpr_sint_t sMsgId = MessageBox(sMsg, XPR_NULL, MB_YESNO | MB_ICONQUESTION);
    if (sMsgId == IDNO)
        return;

    CWaitCursor sWaitCursor;

    HRESULT sHResult;
    xpr_tchar_t sQuickLaunch[XPR_MAX_PATH + 1] = {0};
    sHResult = ::SHGetSpecialFolderPath(XPR_NULL, sQuickLaunch, CSIDL_APPDATA, XPR_FALSE);
    if (FAILED(sHResult))
        return;

    _tcscat(sQuickLaunch, XPR_STRING_LITERAL("\\Microsoft\\Internet Explorer\\Quick Launch"));

    xpr_tchar_t sPath[XPR_MAX_PATH + 1] = {0};
    _tcscpy(sPath, sQuickLaunch);

    xpr_tchar_t *sFileName = sPath + _tcslen(sPath) + 1;
    _tcscat(sPath, XPR_STRING_LITERAL("\\*.*"));

    WIN32_FIND_DATA sFindData = {0};
    HANDLE sFindHandle = ::FindFirstFile(sPath, &sFindData);
    if (sFindHandle == INVALID_HANDLE_VALUE)
        return;

    xpr_tchar_t *sExt;
    LPITEMIDLIST sFullPidl = XPR_NULL;
    LPITEMIDLIST sResolvedFullPidl = XPR_NULL;
    BookmarkItem *sBookmarkItem;
    xpr_bool_t sResolved;

    do
    {
        if (_tcscmp(sFindData.cFileName, XPR_STRING_LITERAL(".")) == 0 || _tcscmp(sFindData.cFileName, XPR_STRING_LITERAL("..")) == 0)
            continue;

        _tcscpy(sFileName, sFindData.cFileName);
        sHResult = fxfile::base::Pidl::create(sPath, sFullPidl);
        if (SUCCEEDED(sHResult) && sFullPidl != XPR_NULL)
        {
            sExt = (xpr_tchar_t *)GetFileExt(sFindData.cFileName);
            if (sExt != XPR_NULL && !_tcsicmp(sExt+1, XPR_STRING_LITERAL("lnk")))
            {
                sResolved = ResolveShortcut(GetSafeHwnd(), sPath, &sResolvedFullPidl);
                if (sResolved && sResolvedFullPidl)
                {
                    COM_FREE(sFullPidl);
                    sFullPidl = sResolvedFullPidl;
                }
                else
                {
                    COM_FREE(sResolvedFullPidl);
                }
            }

            sBookmarkItem = new BookmarkItem;

            Pidl2Path(sFullPidl, sBookmarkItem->mPath);
            GetName(sFullPidl, SHGDN_INFOLDER, sBookmarkItem->mName);

            addBookmark(sBookmarkItem, IconReqShellIcon);
        }

        COM_FREE(sFullPidl);
    }
    while (::FindNextFile(sFindHandle, &sFindData) == XPR_TRUE);

    ::FindClose(sFindHandle);

    if (mListCtrl.GetItemCount() > 0)
        setItemFocus(0);

    updateStatus();
}
コード例 #10
0
DualErr 
CPGPdiskApp::CanonicalizeAppCommandInfo(PAppCommandInfo pACI)
{
	DualErr derr;

	try
	{
		AppOp		op;
		CString		path;
		PGPdisk		*pPGD;
		PGPUInt8	drive;

		pgpAssertAddrValid(pACI, AppCommandInfo);

		op		= pACI->op;
		path	= pACI->path;
		drive	= pACI->drive;

		// Only some commands need pre-processing.
		switch (op)
		{
		case kAppOp_Mount:

			// Resolve any shortcut.
			if (IsShortCut(path))
				derr = ResolveShortcut(path, &path);

			if (derr.IsntError())
			{
				// Resolve 'root' forms to the corresponding PGPdisk.
				if (IsPlainLocalRoot(path))
				{
					pPGD = mPGPdisks.FindPGPdisk(DriveFromPath(path));

					if (NULL!=(int)(pPGD))
						path = pPGD->GetPath();
				}

				// Pretty the path.
				derr = VerifyAndCanonicalizePath(path, &path);
			}
			break;

		case kAppOp_AddPassphrase:
		case kAppOp_ChangePassphrase:
		case kAppOp_RemovePassphrase:
		case kAppOp_RemoveAlternates:
		case kAppOp_AddRemovePublicKeys:
		case kAppOp_WipePassesThisDisk:

			// Resolve any shortcut.
			if (IsShortCut(path))
				derr = ResolveShortcut(path, &path);

			if (derr.IsntError())
			{
				// Pretty the path.
				derr = VerifyAndCanonicalizePath(path, &path);
			}
			break;

		case kAppOp_Unmount:

			// If we don't have a drive, check for path.
			if (!IsLegalDriveNumber(drive))
			{
				pgpAssert(!path.IsEmpty());

				// Resolve any shortcut.
				if (IsShortCut(path))
					derr = ResolveShortcut(path, &path);

				// Extract the drive letter.
				if (derr.IsntError())
				{
					if (IsPlainLocalRoot(path))
					{
						// We have a root to a PGPdisk volume.
						drive = DriveLetToNum(path[0]);
					}
					else
					{
						// We have a path to a PGPdisk file.
						derr = VerifyAndCanonicalizePath(path, &path);

						if (derr.IsntError())
						{
							pPGD = mPGPdisks.FindPGPdisk(path);

							if (NULL!=(int)(pPGD))
								drive = pPGD->GetDrive();
						}
					}
				}
			}
			break;
		}

		// Update the ACI with the modified values.
		if (derr.IsntError())
		{
			strcpy(pACI->path, path);
			pACI->drive = drive;
		}
	}
	catch (CMemoryException *ex)
	{
		derr = DualErr(kPGDMinorError_OutOfMemory);
		ex->Delete();
	}

	return derr;
}