ReactOS 0.4.16-dev-303-g11d5cb8
ExplorerCmd Struct Reference

Explorer command line parser. More...

#include <explorer.h>

Collaboration diagram for ExplorerCmd:

Public Member Functions

 ExplorerCmd ()
 
 ExplorerCmd (LPCTSTR url, bool mdi)
 
bool ParseCmdLine (LPCTSTR lpCmdLine)
 
bool EvaluateOption (LPCTSTR option)
 
bool IsValidPath () const
 

Public Attributes

String _path
 
WCHAR szPath [MAX_PATH]
 
int _flags
 
int _cmdShow
 
bool _mdi
 
bool _valid_path
 

Detailed Description

Explorer command line parser.

Definition at line 89 of file explorer.h.

Constructor & Destructor Documentation

◆ ExplorerCmd() [1/2]

ExplorerCmd::ExplorerCmd ( )
inline

Definition at line 91 of file explorer.h.

92 : _flags(0),
94 _mdi(false),
95 _valid_path(false)
96 {
97 }
int _flags
Definition: explorer.h:114
bool _valid_path
Definition: explorer.h:117
bool _mdi
Definition: explorer.h:116
int _cmdShow
Definition: explorer.h:115
#define SW_SHOWNORMAL
Definition: winuser.h:773

◆ ExplorerCmd() [2/2]

ExplorerCmd::ExplorerCmd ( LPCTSTR  url,
bool  mdi 
)
inline

Definition at line 99 of file explorer.h.

100 : _path(url),
101 _flags(0),
103 _mdi(mdi),
104 _valid_path(true) //@@
105 {
106 }
static const WCHAR url[]
Definition: encode.c:1432
String _path
Definition: explorer.h:112

Member Function Documentation

◆ EvaluateOption()

bool ExplorerCmd::EvaluateOption ( LPCTSTR  option)

Definition at line 777 of file explorer.cpp.

778{
779 String opt_str;
780
781 // Remove quote characters, as they are evaluated at this point.
782 for(; *option; ++option)
783 if (*option != '"')
784 opt_str += *option;
785
786 option = opt_str;
787
788 if (option[0] == '/') {
789 ++option;
790
791 // option /e for windows in explorer mode
792 if (!_tcsicmp(option, TEXT("e")))
794 // option /root for rooted explorer windows
795 else if (!_tcsicmp(option, TEXT("root")))
797 // non-standard options: /mdi, /sdi
798 else if (!_tcsicmp(option, TEXT("mdi")))
799 _mdi = true;
800 else if (!_tcsicmp(option, TEXT("sdi")))
801 _mdi = false;
802 else if (!_tcsicmp(option, TEXT("n")))
803 {
804 // Do nothing
805 }
806 else if (!_tcsicmp(option, TEXT("select")))
807 {
808 SelectOpt = TRUE;
809 }
810 else
811 return false;
812
813 } else {
814 if (!_path.empty())
815 return false;
816
817 if((SelectOpt == TRUE) && (PathFileExists(option)))
818 {
819 WCHAR szDir[MAX_PATH];
820
821 _wsplitpath(option, szPath, szDir, NULL, NULL);
822 wcscat(szPath, szDir);
824 _path = szPath;
826 }
827 else
828 _path = opt_str;
829 }
830
831 return true;
832}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
_CRTIMP void __cdecl _wsplitpath(_In_z_ const wchar_t *_FullPath, _Pre_maybenull_ _Post_z_ wchar_t *_Drive, _Pre_maybenull_ _Post_z_ wchar_t *_Dir, _Pre_maybenull_ _Post_z_ wchar_t *_Filename, _Pre_maybenull_ _Post_z_ wchar_t *_Ext)
#define TEXT(s)
Definition: k32.h:26
@ OWM_EXPLORE
Definition: mainframe.h:32
@ OWM_ROOTED
window in explore mode
Definition: mainframe.h:33
boolean SelectOpt
Definition: explorer.cpp:53
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define PathRemoveBackslash
Definition: shlwapi.h:1049
#define PathFileExists
Definition: shlwapi.h:925
WCHAR szPath[MAX_PATH]
Definition: explorer.h:113
Definition: getopt.h:109
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _tcsicmp
Definition: xmlstorage.h:205

Referenced by ParseCmdLine().

◆ IsValidPath()

bool ExplorerCmd::IsValidPath ( ) const

Definition at line 834 of file explorer.cpp.

835{
836 if (!_path.empty()) {
838
840 return true; // file system path
841 else if (*_path==':' && _path.at(1)==':')
842 return true; // text encoded IDL
843 }
844
845 return false;
846}
unsigned long DWORD
Definition: ntddk_ex.h:95
const GLint * attribs
Definition: glext.h:10538
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define GetFileAttributes
Definition: winbase.h:3840

◆ ParseCmdLine()

bool ExplorerCmd::ParseCmdLine ( LPCTSTR  lpCmdLine)

Definition at line 733 of file explorer.cpp.

734{
735 bool ok = true;
736
737 LPCTSTR b = lpCmdLine;
738 LPCTSTR p = b;
739
740 while(*b) {
741 // remove leading space
742 while(_istspace((unsigned)*b))
743 ++b;
744
745 p = b;
746
747 bool quote = false;
748
749 // options are separated by ','
750 for(; *p; ++p) {
751 if (*p == '"') // Quote characters may appear at any position in the command line.
752 quote = !quote;
753 else if (*p==',' && !quote)
754 break;
755 }
756
757 if (p > b) {
758 int l = p - b;
759
760 // remove trailing space
761 while(l>0 && _istspace((unsigned)b[l-1]))
762 --l;
763
764 if (!EvaluateOption(String(b, l)))
765 ok = false;
766
767 if (*p)
768 ++p;
769
770 b = p;
771 }
772 }
773
774 return ok;
775}
#define ok(value,...)
Definition: atltest.h:57
r l[0]
Definition: byte_order.h:168
static const WCHAR quote[]
Definition: reg.c:40
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
#define _istspace
Definition: tchar.h:1504
#define b
Definition: ke_i.h:79
bool EvaluateOption(LPCTSTR option)
Definition: explorer.cpp:777
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Member Data Documentation

◆ _cmdShow

int ExplorerCmd::_cmdShow

Definition at line 115 of file explorer.h.

◆ _flags

int ExplorerCmd::_flags

Definition at line 114 of file explorer.h.

Referenced by EvaluateOption().

◆ _mdi

bool ExplorerCmd::_mdi

Definition at line 116 of file explorer.h.

Referenced by EvaluateOption().

◆ _path

String ExplorerCmd::_path

Definition at line 112 of file explorer.h.

Referenced by EvaluateOption(), and IsValidPath().

◆ _valid_path

bool ExplorerCmd::_valid_path

Definition at line 117 of file explorer.h.

◆ szPath

WCHAR ExplorerCmd::szPath[MAX_PATH]

Definition at line 113 of file explorer.h.

Referenced by EvaluateOption().


The documentation for this struct was generated from the following files: