File tree Expand file tree Collapse file tree 5 files changed +44
-45
lines changed
Expand file tree Collapse file tree 5 files changed +44
-45
lines changed Original file line number Diff line number Diff line change @@ -135,24 +135,6 @@ namespace shellanything
135135 // / <returns>Returns true if the given context is valid against the set of constraints. Returns false otherwise.</returns>
136136 bool Validate (const Context & iContext) const ;
137137
138- public:
139-
140- // / <summary>
141- // / Returns the drive letter of the given path.
142- // / Returns an empty string if the element is not mapped to a drive.
143- // / </summary>
144- // / <param name="element">The path to an element.</param>
145- // / <returns>Returns the drive letter of the given path. Returns an empty string if the element is not mapped to a drive.</returns>
146- static std::string GetDriveLetter (const std::string & element);
147-
148- // / <summary>
149- // / Returns the drive path of the given path. The drive path is returned as 3 characters path. For example "C:\".
150- // / Returns an empty string if the element is not mapped to a drive.
151- // / </summary>
152- // / <param name="element">The path to an element.</param>
153- // / <returns>Returns the drive path of the given path. Returns an empty string if the element is not mapped to a drive.</returns>
154- static std::string GetDrivePath (const std::string & element);
155-
156138 private:
157139 bool ValidateProperties (const Context & context, const std::string & properties, bool inversed) const ;
158140 bool ValidateFileExtensions (const Context & context, const std::string & file_extensions, bool inversed) const ;
Original file line number Diff line number Diff line change 2525#include " shellanything/Context.h"
2626#include " shellanything/Validator.h"
2727#include " PropertyManager.h"
28+ #include " DriveClass.h"
2829
2930#include " rapidassist/filesystem_utf8.h"
3031#include " rapidassist/environment_utf8.h"
@@ -100,8 +101,8 @@ namespace shellanything
100101 std::string element_selection_filename = ra::filesystem::GetFilename (element_selection_path.c_str ());
101102 std::string element_selection_filename_noext = ra::filesystem::GetFilenameWithoutExtension (element_selection_path.c_str ());
102103 std::string element_selection_filename_ext = ra::filesystem::GetFileExtention (element_selection_filename);
103- std::string element_selection_drive_letter = Validator:: GetDriveLetter (element);
104- std::string element_selection_drive_path = Validator:: GetDrivePath (element);
104+ std::string element_selection_drive_letter = GetDriveLetter (element);
105+ std::string element_selection_drive_path = GetDrivePath (element);
105106
106107 // Add a separator between values
107108 if (!selection_path .empty ()) selection_path .append ( selection_multi_separator );
Original file line number Diff line number Diff line change 3030namespace shellanything
3131{
3232
33+ inline bool IsDriveLetter (char c)
34+ {
35+ if ( (c >= ' a' && c <= ' z' ) ||
36+ (c >= ' A' && c <= ' Z' ) )
37+ return true ;
38+ return false ;
39+ }
40+
41+ std::string GetDriveLetter (const std::string & element)
42+ {
43+ std::string letter;
44+ if (element.size () >= 2 && element[1 ] == ' :' && IsDriveLetter (element[0 ]))
45+ letter.append (1 , element[0 ]);
46+ return letter;
47+ }
48+
49+ std::string GetDrivePath (const std::string & element)
50+ {
51+ std::string letter;
52+ if (element.size () >= 3 && element[1 ] == ' :' && IsDriveLetter (element[0 ]) && element[2 ] == ' \\ ' )
53+ letter.append (element.c_str (), 3 );
54+ return letter;
55+ }
56+
3357 bool IsNetworkPath (const std::string & path)
3458 {
3559 if (path.size () >= 2 && path.substr (0 , 2 ) == " \\\\ " )
@@ -73,7 +97,7 @@ namespace shellanything
7397 // The functions returns DRIVE_NO_ROOT_DIR even if the drive letter, of the given non-existing path, is a CD-ROM or DVD-Drive.
7498 // However, the function will return DRIVE_CDROM is the root path of the same path is used, even if there are no disk in the optical drive.
7599 // To work around these issues, try to resolve with the root path of the drive.
76- std::string root_path = Validator:: GetDrivePath (path);
100+ std::string root_path = GetDrivePath (path);
77101 if (root_path.empty () || // We may be dealing with a network path
78102 root_path == path ) // We are already using a root drive path
79103 {
Original file line number Diff line number Diff line change @@ -40,6 +40,22 @@ namespace shellanything
4040 DRIVE_CLASS_RAMDISK
4141 };
4242
43+ // / <summary>
44+ // / Returns the drive letter of the given path.
45+ // / Returns an empty string if the element is not mapped to a drive.
46+ // / </summary>
47+ // / <param name="element">The path to an element.</param>
48+ // / <returns>Returns the drive letter of the given path. Returns an empty string if the element is not mapped to a drive.</returns>
49+ std::string GetDriveLetter (const std::string & element);
50+
51+ // / <summary>
52+ // / Returns the drive path of the given path. The drive path is returned as 3 characters path. For example "C:\".
53+ // / Returns an empty string if the element is not mapped to a drive.
54+ // / </summary>
55+ // / <param name="element">The path to an element.</param>
56+ // / <returns>Returns the drive path of the given path. Returns an empty string if the element is not mapped to a drive.</returns>
57+ std::string GetDrivePath (const std::string & element);
58+
4359 // / <summary>
4460 // / Define if the given path is a network path.
4561 // / The given path do not need to exist to be identified as a network path.
Original file line number Diff line number Diff line change @@ -272,30 +272,6 @@ namespace shellanything
272272 return true ;
273273 }
274274
275- inline bool IsDriveLetter (char c)
276- {
277- if ( (c >= ' a' && c <= ' z' ) ||
278- (c >= ' A' && c <= ' Z' ) )
279- return true ;
280- return false ;
281- }
282-
283- std::string Validator::GetDriveLetter (const std::string & element)
284- {
285- std::string letter;
286- if (element.size () >= 2 && element[1 ] == ' :' && IsDriveLetter (element[0 ]))
287- letter.append (1 , element[0 ]);
288- return letter;
289- }
290-
291- std::string Validator::GetDrivePath (const std::string & element)
292- {
293- std::string letter;
294- if (element.size () >= 3 && element[1 ] == ' :' && IsDriveLetter (element[0 ]) && element[2 ] == ' \\ ' )
295- letter.append (element.c_str (), 3 );
296- return letter;
297- }
298-
299275 bool Validator::ValidateProperties (const Context & context, const std::string & properties, bool inversed) const
300276 {
301277 if (properties.empty ())
You can’t perform that action at this time.
0 commit comments