ReactOS  0.4.15-dev-1200-gc3b3fcd
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  }
bool _valid_path
Definition: explorer.h:117
int _flags
Definition: explorer.h:114
int _cmdShow
Definition: explorer.h:115
bool _mdi
Definition: explorer.h:116
#define SW_SHOWNORMAL
Definition: winuser.h:764

◆ 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  }
bool _valid_path
Definition: explorer.h:117
int _flags
Definition: explorer.h:114
static const WCHAR url[]
Definition: encode.c:1432
int _cmdShow
Definition: explorer.h:115
String _path
Definition: explorer.h:112
bool _mdi
Definition: explorer.h:116
#define SW_SHOWNORMAL
Definition: winuser.h:764

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")))
793  _flags |= OWM_EXPLORE;
794  // option /root for rooted explorer windows
795  else if (!_tcsicmp(option, TEXT("root")))
796  _flags |= OWM_ROOTED;
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;
825  SelectOpt = FALSE;
826  }
827  else
828  _path = opt_str;
829  }
830 
831  return true;
832 }
void _wsplitpath(const WCHAR *path, WCHAR *drv, WCHAR *dir, WCHAR *name, WCHAR *ext)
Definition: splitpath.c:22
#define _tcsicmp
Definition: xmlstorage.h:205
#define TRUE
Definition: types.h:120
static WCHAR String[]
Definition: stringtable.c:55
int _flags
Definition: explorer.h:114
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
Definition: getopt.h:108
GLuint GLenum option
Definition: glext.h:11211
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define PathRemoveBackslash
Definition: shlwapi.h:1023
#define MAX_PATH
Definition: compat.h:34
String _path
Definition: explorer.h:112
bool _mdi
Definition: explorer.h:116
boolean SelectOpt
Definition: explorer.cpp:53
#define PathFileExists
Definition: shlwapi.h:899
#define TEXT(s)
Definition: k32.h:26
WCHAR szPath[MAX_PATH]
Definition: explorer.h:113
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
window in explore mode
Definition: mainframe.h:33

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 }
const GLint * attribs
Definition: glext.h:10538
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
String _path
Definition: explorer.h:112
#define GetFileAttributes
Definition: winbase.h:3655

◆ 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 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
bool EvaluateOption(LPCTSTR option)
Definition: explorer.cpp:777
static WCHAR String[]
Definition: stringtable.c:55
#define quote
Definition: macro.lex.yy.c:531
#define b
Definition: ke_i.h:79
r l[0]
Definition: byte_order.h:167
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define ok(value,...)
Definition: atltest.h:57
#define _istspace
Definition: tchar.h:1504
GLfloat GLfloat p
Definition: glext.h:8902

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: