forked from maraf/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakepath.cpp
More file actions
52 lines (46 loc) · 1.25 KB
/
makepath.cpp
File metadata and controls
52 lines (46 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/***
*makepath.c - create path name from components
*
*
*Purpose:
* To provide support for creation of full path names from components
*
*******************************************************************************/
#include "stdafx.h"
#include "utilcode.h"
#include "ex.h"
// Returns the directory for clr module. So, if path was for "C:\Dir1\Dir2\Filename.DLL",
// then this would return "C:\Dir1\Dir2\" (note the trailing backslash).HRESULT GetClrModuleDirectory(SString& wszPath)
HRESULT GetClrModuleDirectory(SString& wszPath)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
CANNOT_TAKE_LOCK;
}
CONTRACTL_END;
DWORD dwRet = GetClrModulePathName(wszPath);
if (dwRet == 0)
{ // Some other error.
return HRESULT_FROM_GetLastError();
}
HRESULT hr = S_OK;
EX_TRY
{
SString::Iterator iter = wszPath.End();
if (wszPath.FindBack(iter,DIRECTORY_SEPARATOR_CHAR_W))
{
iter++;
wszPath.Truncate(iter);
}
else
{
hr = E_UNEXPECTED;
}
}
EX_CATCH_HRESULT(hr);
return hr;
}