OLD | NEW |
| (Empty) |
1 // Copyright 2007-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 // | |
16 // Path utility functions. | |
17 | |
18 #ifndef OMAHA_BASE_PATH_H_ | |
19 #define OMAHA_BASE_PATH_H_ | |
20 | |
21 #include <atlstr.h> | |
22 #include <vector> | |
23 | |
24 namespace omaha { | |
25 | |
26 // Get the starting path from the command string | |
27 CString GetStartingPathFromString(const CString& s); | |
28 | |
29 // Get the trailing path from the command string | |
30 CString GetTrailingPathFromString(const CString& s); | |
31 | |
32 // Get the file from the command string | |
33 HRESULT GetFileFromCommandString(const TCHAR* s, CString* file); | |
34 | |
35 // Expands the string with embedded special folder variables | |
36 HRESULT ExpandStringWithSpecialFolders(CString* str); | |
37 | |
38 // Normalize a path | |
39 HRESULT NormalizePath(const TCHAR* path, CString* normalized_path); | |
40 | |
41 // Concatenate two paths together | |
42 CString ConcatenatePath(const CString& path1, const CString& path2); | |
43 | |
44 // Get the file out of the file path | |
45 CString GetFileFromPath(const CString& path); | |
46 | |
47 // Get the directory from the path | |
48 CString GetDirectoryFromPath(const CString& path); | |
49 | |
50 // Remove the extension from the path. | |
51 CString GetPathRemoveExtension(const CString& path); | |
52 | |
53 // Returns true iff path is an absolute path (starts with a drive name) | |
54 bool IsAbsolutePath(const TCHAR* path); | |
55 | |
56 // Makes sure the path is enclosed with double quotation marks. | |
57 void EnclosePath(CString* path); | |
58 | |
59 // Used to enclose paths that are typically used with LocalServer32 entries. | |
60 // Unenclosed LocalServer32 entries with spaces are not recommended because | |
61 // the LocalServer32 entry is a command line, not just an EXE path. | |
62 // DLL paths should not be enclosed, because InProcServer32 entries are just | |
63 // a DLL path and not a command line. | |
64 CString EnclosePathIfExe(const CString& module_path); | |
65 | |
66 // remove any double quotation masks from an enclosed path | |
67 void UnenclosePath(CString* path); | |
68 | |
69 // Removes a trailing double quote from a path. ::CommandLineToArgvW() has some | |
70 // strange treatment for quotation marks and backslashes, as detailed here: | |
71 // http://blogs.msdn.com/b/oldnewthing/archive/2010/09/17/10063629.aspx | |
72 // | |
73 // So an argument containing a directory path with a trailing backslash: | |
74 // <<prog.exe /dir "c:\a dir\">> | |
75 // is incorrectly parsed with a double-quote at the end: | |
76 // <<c:\a dir">>. | |
77 void RemoveMismatchedEndQuoteInDirectoryPath(CString* directory_path); | |
78 | |
79 // Converts the short path name to long name. | |
80 HRESULT ShortPathToLongPath(const CString& short_path, CString* long_path); | |
81 | |
82 // Returns a list of files that match the criteria. | |
83 HRESULT FindFiles(const CString& dir, | |
84 const CString& pattern, | |
85 std::vector<CString>* files); | |
86 | |
87 HRESULT FindFilesEx(const CString& dir, | |
88 const CString& pattern, | |
89 std::vector<CString>* files); | |
90 | |
91 HRESULT FindFileRecursive(const CString& dir, | |
92 const CString& pattern, | |
93 std::vector<CString>* files); | |
94 | |
95 } // namespace omaha | |
96 | |
97 #endif // OMAHA_BASE_PATH_H_ | |
OLD | NEW |