FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TF2-Source-Code/tf2_src/tier2/p4helpers.cpp at master · sr2echa/TF2-Source-Code · GitHub
sr2echa
/
TF2-Source-Code
Public
Notifications
You must be signed in to change notification settings
Fork
22
Star
81
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TF2-Source-Code
/
tf2_src
/
tier2
/
p4helpers.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
138 lines (105 loc) · 2.86 KB
Breadcrumbs
TF2-Source-Code
/
tf2_src
/
tier2
/
p4helpers.cpp
Copy path
File metadata and controls
138 lines (105 loc) · 2.86 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//
========= Copyright Valve Corporation, All rights reserved. ============//
//
//
Purpose:
//
//
$NoKeywords: $
//
//
=============================================================================//
#
include
"
p4helpers.h
"
#
include
"
tier2/tier2.h
"
#
include
"
p4lib/ip4.h
"
#
ifdef
PLATFORM_WINDOWS_PC
#
include
<
Windows.h
>
#
endif
//
PLATFORM_WINDOWS_PC
//
////////////////////////////////////////////////////////////////////////
//
//
CP4File implementation
//
//
////////////////////////////////////////////////////////////////////////
CP4File::CP4File
(
char
const
*szFilename )
{
#
ifdef
PLATFORM_WINDOWS_PC
//
On windows, get the pathname of the file on disk first before using that as a perforce path
//
this avoids invalid Adds(). Have to go through GetShortPathName and then GetLongPathName from
//
the short path name
TCHAR
szShortPathName[
MAX_PATH
] =
TEXT
(
"
"
);
const
DWORD
shortRetVal =
GetShortPathName
( szFilename, szShortPathName,
ARRAYSIZE
( szShortPathName ) );
if
( shortRetVal >
0
&& shortRetVal <=
ARRAYSIZE
( szShortPathName ) )
{
TCHAR
szLongPathName[
MAX_PATH
] =
TEXT
(
"
"
);
const
DWORD
longRetVal =
GetLongPathName
( szShortPathName, szLongPathName,
ARRAYSIZE
( szLongPathName ) );
if
( longRetVal >
0
&& longRetVal <=
ARRAYSIZE
( szLongPathName ) )
{
m_sFilename = szLongPathName;
return
;
}
}
#
endif
//
PLATFORM_WINDOWS_PC
m_sFilename = szFilename;
}
CP4File::~CP4File
()
{
}
bool
CP4File::Edit
(
void
)
{
if
( !p4 )
return
true
;
return
p4->
OpenFileForEdit
( m_sFilename.
String
() );
}
bool
CP4File::Add
(
void
)
{
if
( !p4 )
return
true
;
return
p4->
OpenFileForAdd
( m_sFilename.
String
() );
}
bool
CP4File::Revert
(
void
)
{
if
( !p4 )
return
true
;
return
p4->
RevertFile
( m_sFilename.
String
() );
}
//
Is the file in perforce?
bool
CP4File::IsFileInPerforce
()
{
if
( !p4 )
return
false
;
return
p4->
IsFileInPerforce
( m_sFilename.
String
() );
}
bool
CP4File::SetFileType
(
const
CUtlString& desiredFileType)
{
if
( !p4 )
return
false
;
return
p4->
SetFileType
( m_sFilename.
String
(), desiredFileType.
String
() );
}
//
////////////////////////////////////////////////////////////////////////
//
//
CP4Factory implementation
//
//
////////////////////////////////////////////////////////////////////////
CP4Factory::CP4Factory
()
{
}
CP4Factory::~CP4Factory
()
{
}
bool
CP4Factory::SetDummyMode
(
bool
bDummyMode )
{
bool
bOld = m_bDummyMode;
m_bDummyMode = bDummyMode;
return
bOld;
}
void
CP4Factory::SetOpenFileChangeList
(
const
char
*szChangeListName )
{
if
( !m_bDummyMode && p4 )
p4->
SetOpenFileChangeList
( szChangeListName );
}
CP4File *
CP4Factory::AccessFile
(
char
const
*szFilename )
const
{
if
( !m_bDummyMode )
return
new
CP4File
( szFilename );
else
return
new
CP4File_Dummy
( szFilename );
}
//
Default p4 factory
static
CP4Factory s_static_p4_factory;
CP4Factory *g_p4factory = &s_static_p4_factory;
//
NULL before the factory constructs
Back
|
FazBrowse Home
|
New Git URL