ngsplitpath.cpp

来自「ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - 」· C++ 代码 · 共 62 行

CPP
62
字号
//////////////////////////////////////////////////////////////////////
// NGSplitPath.cpp : implementation of the CNGSplitPath class.          //
// (c) 1999, Kevin Lussier                                          //
//////////////////////////////////////////////////////////////////////

#include "StdAfx.h"

#include "NGSplitPath.h"


#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif


CNGSplitPath::CNGSplitPath(LPCTSTR lpszPath)
{
    // Initialize our objects
    memset( szPath, 0, sizeof( szPath ) );
    memset( szDrive, 0, sizeof( szDrive ) );
    memset( szDir, 0, sizeof( szDir ) );
    memset( szFilename, 0, sizeof( szFilename ) );
    memset( szExtension, 0, sizeof( szExtension ) );

    // If we were given a path, split it
    if (lpszPath != NULL)
	{
        Split(lpszPath);
    }
}

BOOL CNGSplitPath::Split(LPCTSTR lpszPath)
{
    // If we weren't given a path, fail
    if ( lpszPath == NULL )
	{
        // Return failure
        return FALSE;
    }

    // Copy the path
    _tcsncpy( szPath, lpszPath, sizeof( szPath ) - 1 );

    // Split the given path
    _tsplitpath( szPath, szDrive, szDir, szFilename, szExtension );

	// If UNC name
	if ( !_tcsncmp(szDir, "\\\\", 2))
	{
		// Get the computername
		_tcsncpy(szComputer, _tcsstr(szDir, "\\\\")+2, sizeof(szComputer)-1 );
		_tcsnset(_tcsstr(szComputer, "\\"), 0, 1);

		// Strip the computername from the directory
		_tcsncpy(szDir, _tcsstr(szDir, "\\\\")+2, sizeof(szDir)-1 );
		_tcsncpy(szDir, _tcsstr(szDir, "\\"), sizeof(szDir)-1 );
	}
	return TRUE;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?