Esempio n. 1
0
CString COptions::FindFile(CString name)
{
    CFileFind finder;
    CString res;
    res.Format(_T("%s%s"), AddBackslash(GetAppPath()), name);
    BOOL found = finder.FindFile(res);
    if (!found)	{
        res.Format(_T("%s..\\%s"), AddBackslash(GetAppPath()), name);
        found = finder.FindFile(res);
        if (!finder.FindFile(res)) {
            res.Format(_T("%s..\\doc\\%s"), AddBackslash(GetAppPath()), name);
            if (!finder.FindFile(res))
                res.Empty();
        }
    }
    finder.Close();
    return res;
}
Esempio n. 2
0
CFilePath &CFilePath::Append(LPCTSTR psString)
{
    if (psString == NULL || *psString == '\0')
    {
        AddBackslash();
    } else
    {
        int nLen = psString ? _tcslen(psString) : 0;
        CStringLock Buffer(msPath, msPath.GetLength() + nLen + 1);
        PathAppend(Buffer, psString);
    }

    return *this;
}
Esempio n. 3
0
VOID NEAR PASCAL InitMenus()
{
  WORD i;
  HMENU hMenu;
  OFSTRUCT os;
  INT iMax;
  CHAR szValue[MAXPATHLEN];
  HWND hwndActive;

  ENTER("InitMenus");

  hwndActive = (HWND)SendMessage(hwndMDIClient, WM_MDIGETACTIVE, 0, 0L);
  if (hwndActive && GetWindowLong(hwndActive, GWL_STYLE) & WS_MAXIMIZE)
      iMax = 1;
  else
      iMax = 0;

  GetPrivateProfileString(szSettings, szUndelete, szNULL, szValue, sizeof(szValue), szTheINIFile);

  if (szValue[0]) {

        // create explicit filename to avoid searching the path

        GetSystemDirectory(os.szPathName, sizeof(os.szPathName));
        AddBackslash(os.szPathName);
        lstrcat(os.szPathName, szValue);

        if (MOpenFile(os.szPathName, &os, OF_EXIST) > 0) {

                hModUndelete = MLoadLibrary(szValue);

                if (hModUndelete >= (HANDLE)32) {
                    lpfpUndelete = (FM_UNDELETE_PROC)GetProcAddress(hModUndelete, "UndeleteFile");

                        if (lpfpUndelete) {
                                hMenu = GetSubMenu(GetMenu(hwndFrame), IDM_FILE + iMax);
                                LoadString(hAppInstance, IDS_UNDELETE, szValue, sizeof(szValue));
                                InsertMenu(hMenu, 4, MF_BYPOSITION | MF_STRING, IDM_UNDELETE, szValue);
                        }
                } else {
                        FreeLibrary(hModUndelete);

                }
        }
  }

  /* Init the Disk menu. */
  hMenu = GetMenu(hwndFrame);

  if (nFloppies == 0)
    {
      EnableMenuItem(hMenu, IDM_DISKCOPY, MF_BYCOMMAND | MF_GRAYED);
      EnableMenuItem(hMenu, IDM_FORMAT,   MF_BYCOMMAND | MF_GRAYED);
      EnableMenuItem(hMenu, IDM_SYSDISK,  MF_BYCOMMAND | MF_GRAYED);
    }

  bNetAdmin = WNetGetCaps(WNNC_ADMIN) & WNNC_ADM_GETDIRECTORYTYPE;

  /* Should we enable the network items? */
  i = (WORD)WNetGetCaps(WNNC_DIALOG);

  i = 0;

  bConnect    = i & WNNC_DLG_ConnectDialog;     // note, these should both
  bDisconnect = i & WNNC_DLG_DisconnectDialog;  // be true or both false

  // use submenu because we are doing this by position

  hMenu = GetSubMenu(GetMenu(hwndFrame), IDM_DISK + iMax);

  if (i)
        InsertMenu(hMenu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);

  if (bConnect && bDisconnect) {

        // lanman style double connect/disconnect

        LoadString(hAppInstance, IDS_CONNECT, szValue, sizeof(szValue));
        InsertMenu(hMenu, 6, MF_BYPOSITION | MF_STRING, IDM_CONNECT, szValue);
        LoadString(hAppInstance, IDS_DISCONNECT, szValue, sizeof(szValue));
        InsertMenu(hMenu, 7, MF_BYPOSITION | MF_STRING, IDM_DISCONNECT, szValue);
  } else if (WNetGetCaps(WNNC_CONNECTION)) {

  }

  hMenu = GetMenu(hwndFrame);

  if (bStatusBar)
      CheckMenuItem(hMenu, IDM_STATUSBAR, MF_BYCOMMAND | MF_CHECKED);
  if (bMinOnRun)
      CheckMenuItem(hMenu, IDM_MINONRUN,  MF_BYCOMMAND | MF_CHECKED);
  if (bSaveSettings)
      CheckMenuItem(hMenu, IDM_SAVESETTINGS,  MF_BYCOMMAND | MF_CHECKED);

  InitDriveBitmaps();

  InitExtensions();

  LEAVE("InitMenus");
}
Esempio n. 4
0
BOOL LoadIME(
    PIMEINFOEX piiex,
    PIMEDPI    pImeDpi)
{
    WCHAR wszImeFile[MAX_PATH];
    BOOL  fSuccess;
    UINT  i;

    i = GetSystemDirectoryW(wszImeFile, MAX_PATH);
    wszImeFile[i] = L'\0';
    AddBackslash(wszImeFile);
    wcscat(wszImeFile, piiex->wszImeFile);

    pImeDpi->hInst = LoadLibraryW(wszImeFile);

    if (!pImeDpi->hInst) {
        RIPMSG1(RIP_WARNING, "LoadIME: LoadLibraryW(%ws) failed", wszImeFile);
        goto LoadIME_ErrOut;
    }

#define GET_IMEPROCT(x) \
    if (!(pImeDpi->pfn.##x.t = (PVOID) GetProcAddress(pImeDpi->hInst, #x))) { \
        RIPMSG1(RIP_WARNING, "LoadIME: " #x " not supported in %ws", wszImeFile);           \
        goto LoadIME_ErrOut; }

#define GET_IMEPROC(x) \
    if (!(pImeDpi->pfn.##x = (PVOID) GetProcAddress(pImeDpi->hInst, #x))) {   \
        RIPMSG1(RIP_WARNING, "LoadIME: " #x " not supported in %ws", wszImeFile);           \
        goto LoadIME_ErrOut; }

    GET_IMEPROCT(ImeInquire);
    GET_IMEPROCT(ImeConversionList);
    GET_IMEPROCT(ImeRegisterWord);
    GET_IMEPROCT(ImeUnregisterWord);
    GET_IMEPROCT(ImeGetRegisterWordStyle);
    GET_IMEPROCT(ImeEnumRegisterWord);
    GET_IMEPROC (ImeConfigure);
    GET_IMEPROC (ImeDestroy);
    GET_IMEPROC (ImeEscape);
    GET_IMEPROC (ImeProcessKey);
    GET_IMEPROC (ImeSelect);
    GET_IMEPROC (ImeSetActiveContext);
    GET_IMEPROC (ImeToAsciiEx);
    GET_IMEPROC (NotifyIME);
    GET_IMEPROC (ImeSetCompositionString);

#undef GET_IMEPROCT
#undef GET_IMEPROC

    if (!InquireIme(pImeDpi)) {
        RIPMSG0(RIP_WARNING, "LoadIME: InquireIme failed");
LoadIME_ErrOut:
        FreeLibrary(pImeDpi->hInst);
        pImeDpi->hInst = NULL;
        fSuccess = FALSE;
    }
    else {
        fSuccess = TRUE;
    }

    /*
     * Update kernel side IMEINFOEX for this keyboard layout if
     * this is its first loading.
     */
    if (piiex->fLoadFlag == IMEF_NONLOAD) {
        if (fSuccess) {
            RtlCopyMemory((PBYTE)&piiex->ImeInfo,
                          (PBYTE)&pImeDpi->ImeInfo, sizeof(IMEINFO));
            RtlCopyMemory((PBYTE)piiex->wszUIClass,
                          (PBYTE)pImeDpi->wszUIClass, sizeof(pImeDpi->wszUIClass));
            piiex->fLoadFlag = IMEF_LOADED;
        }
        else {
            piiex->fLoadFlag = IMEF_LOADERROR;
        }
        NtUserSetImeInfoEx(piiex);
    }

    return fSuccess;
}
Esempio n. 5
0
CString COptions::GetLangDir()
{
    return AddBackslash(GetAppPath()) + _T("lang");
}
Esempio n. 6
0
void COptions::UpdateFiles()
{
    m_TemplateFile = AddBackslash(m_ConfigDir) + DEF_BIB_FILE;
    m_EncodingTeX = AddBackslash(m_ConfigDir) + CODING_TEX;
    m_EncodingHTML = AddBackslash(m_ConfigDir) + CODING_HTML;
    m_EncodingRTF = AddBackslash(m_ConfigDir) + CODING_RTF;
    m_EncodingXML = AddBackslash(m_ConfigDir) + CODING_XML;
    m_XSLFilename = AddBackslash(m_ConfigDir) + XSL_FILENAME;
    m_SearchProfilesFile = AddBackslash(m_ConfigDir) + SEARCH_PROFILES;
    m_DefPreviewXSL = AddBackslash(m_ConfigDir) + XSL_PREVIEW;
    m_DefCopyHTMLXSL = AddBackslash(m_ConfigDir) + XSL_COPYHTML;
    m_KeygenXSL = AddBackslash(m_ConfigDir) + XSL_KEYGEN;
    // Load exporter list now
    m_ExporterList->m_ListFile = AddBackslash(m_ConfigDir) + EXPORTER_FILE;
    m_ExporterList->Load(TRUE);
}
Esempio n. 7
0
	// Scan directory. This code get's called on 
	// the spawned thread. It uses recursion to traverse
	// sub-directories when necessary.
	BOOL ScanDirectory( LPCTSTR pszDir )
	{
		ClsString	strPath, str;
		ClsFindFile	find;
		ClsStdioFile	file;

		// Are we still running?
		if ( m_Thread.Wait() != ClsWorkerThread::wtRunning )
			return FALSE;

		// Do we need to scan the sub-directories?
		if ( m_bRecur )
		{
			// Assign path.
			strPath = pszDir;

			// Add a backslash if not yet present.
			AddBackslash( strPath );

			// Add filter.
			strPath += _T( "*.*" );

			// Start the scan.
			if ( find.FindFile( strPath ))
			{
				// Continue until we are done...
				do
				{
					// Still running?
					if ( m_Thread.Wait() != ClsWorkerThread::wtRunning )
					{
						// Close handle and exit.
						find.Close();
						return FALSE;
					}

					// Is this a directory?
					if ( ! find.IsDots() && find.IsDirectory())
					{
						// Get the full path of the directory.
						find.GetFilePath( strPath );

						// Scan this directory. Recursion hard at work...
						if ( ScanDirectory( strPath ) == FALSE )
						{
							// Prolly a shutdown event during
							// recursion. Close handle and return FALSE.
							find.Close();
							return FALSE;
						}
					}
				} while ( find.FindNextFile());
				// Close the handle.
				find.Close();
			}
		}

		// Get the index of the first delimted part of the string.
		int nIndex = m_StrType.GetDelimitedPart( _T( ';' ), 0, str );

		// Valid?
		if ( nIndex > 0 )
		{
			// Scan using all filters.
			do
			{
				// Assign path.
				strPath = pszDir;

				// Add a backslash if necessary.
				AddBackslash( strPath );

				// Add the filter string.
				strPath += str;

				// Scan the directory.
				if ( find.FindFile( strPath ))
				{
					// Continue until we are done.
					do
					{
						// Still running?
						if ( m_Thread.Wait() != ClsWorkerThread::wtRunning )
						{
							// Close handle and exit.
							find.Close();
							return FALSE;
						}

						// We only show the correct files.
						if ( ! find.IsDots() && ! find.IsDirectory())
						{
							// Get the file name.
							ClsString strName;
							if ( find.GetFilePath( strName ))
							{
								// Show the file we are processing. Simply do a PostMessage()
								// to the dialog which handles the GUI stuff. It will also delete
								// the ClsString we allocate here.
								ClsString *pStr = new ClsString( strName );
								PostMessage( THREAD_PROCESSING, 0, ( LPARAM )pStr );

								// Gracefully handle IO errors.
								try
								{
									// Read the file line-by-line...
									TCHAR szBuf[ 4096 ];
									file.Open( strName, _T( "r" ));
									m_nFiles++;
									int nLine = 0;
									
									while ( file.GetS( szBuf, 4096 ))
									{
										// Still running?
										if ( m_Thread.Wait() != ClsWorkerThread::wtRunning )
										{
											// Close the file and the
											// find-file handles and exit.
											file.Close();
											find.Close();
											return FALSE;
										}

										// Get the base pointer of the buffer.
										TCHAR *ptr = szBuf;
										int    nIdx;

										// Increase line number.
										nLine++;

										// Find all occurences on this line.
										BOOL bAnyFound = FALSE;
										while (( _tcslen( ptr )) && (( nIdx = m_BoyerMoore.FindForward( ptr, ( int )_tcslen( ptr ))) >= 0 ))
										{
											// Are we at the first found entry?
											if ( bAnyFound == FALSE )
											{
												// Strip white spaces from the end of the input buffer.
												while ( _istspace( szBuf[ _tcslen( szBuf ) - 1 ] ))
													szBuf[ _tcslen( szBuf ) - 1 ] = 0;

												// Increase lines-found counter.
												m_nLines++;
											}

											// Found a least one.
											bAnyFound = TRUE;

											// Convert the line for print and post it to the
											// main thread for the GUI stuff.
											ClsString *pStr = ConvertForPrint( szBuf );
											PostMessage( THREAD_FOUND, nLine, ( LPARAM )pStr );
											
											// Increase search pointer so we can search the rest of the line.
											ptr += nIdx + 1;
										}
									}
									// Close file.
									file.Close();
								}
								catch( ClsException& )
								{
									// Continue on IO errors...
									continue;
								}
							}
						}
					} while ( find.FindNextFile());
					// Close the handle.
					find.Close();
				}
			// Next filter...
			} while (( nIndex = m_StrType.GetDelimitedPart( _T( ';' ), nIndex, str )) > 0 );
		}
		return TRUE;
	}