ReactOS  0.4.14-dev-1276-g8aa58c1
FileTypeManager Struct Reference

#include <globals.h>

Inheritance diagram for FileTypeManager:
Collaboration diagram for FileTypeManager:

Public Types

typedef map< String, FileTypeInfosuper
 

Public Member Functions

const FileTypeInfooperator[] (String ext)
 
LPCTSTR set_type (struct Entry *entry, bool dont_hide_ext=false)
 

Static Public Member Functions

static bool is_exe_file (LPCTSTR ext)
 

Detailed Description

Definition at line 43 of file globals.h.

Member Typedef Documentation

◆ super

Definition at line 45 of file globals.h.

Member Function Documentation

◆ is_exe_file()

bool FileTypeManager::is_exe_file ( LPCTSTR  ext)
static

Definition at line 150 of file explorer.cpp.

151 {
152  static const LPCTSTR s_executable_extensions[] = {
153  TEXT("COM"),
154  TEXT("EXE"),
155  TEXT("BAT"),
156  TEXT("CMD"),
157  TEXT("CMM"),
158  TEXT("BTM"),
159  TEXT("AWK"),
160  0
161  };
162 
163  TCHAR ext_buffer[_MAX_EXT];
164  const LPCTSTR* p;
165  LPCTSTR s;
166  LPTSTR d;
167 
168  for(s=ext+1,d=ext_buffer; (*d=toupper(*s)); s++)
169  ++d;
170 
171  for(p=s_executable_extensions; *p; p++)
172  if (!lstrcmp(ext_buffer, *p))
173  return true;
174 
175  return false;
176 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
CHAR * LPTSTR
Definition: xmlstorage.h:192
char ext[3]
Definition: mkdosfs.c:358
char TCHAR
Definition: xmlstorage.h:189
int toupper(int c)
Definition: utclib.c:881
#define d
Definition: ke_i.h:81
GLdouble s
Definition: gl.h:2039
#define lstrcmp
Definition: winbase.h:3712
#define _MAX_EXT
Definition: utility.h:76
#define TEXT(s)
Definition: k32.h:26
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by set_type().

◆ operator[]()

Definition at line 179 of file explorer.cpp.

180 {
181  ext.toLower();
182 
183  iterator found = find(ext);
184  if (found != end())
185  return found->second;
186 
187  FileTypeInfo& ftype = super::operator[](ext);
188 
189  ftype._neverShowExt = false;
190 
191  HKEY hkey;
192  TCHAR value[MAX_PATH], display_name[MAX_PATH];
193  LONG valuelen = sizeof(value);
194 
195  if (!RegQueryValue(HKEY_CLASSES_ROOT, ext, value, &valuelen)) {
196  ftype._classname = value;
197 
198  valuelen = sizeof(display_name);
199  if (!RegQueryValue(HKEY_CLASSES_ROOT, ftype._classname, display_name, &valuelen))
200  ftype._displayname = display_name;
201 
202  if (!RegOpenKey(HKEY_CLASSES_ROOT, ftype._classname, &hkey)) {
203  if (!RegQueryValueEx(hkey, TEXT("NeverShowExt"), 0, NULL, NULL, NULL))
204  ftype._neverShowExt = true;
205 
206  RegCloseKey(hkey);
207  }
208  }
209 
210  return ftype;
211 }
#define RegQueryValueEx
Definition: winreg.h:524
management of file types
Definition: globals.h:37
bool _neverShowExt
Definition: globals.h:40
GLuint GLuint end
Definition: gl.h:1545
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
String _displayname
Definition: globals.h:39
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
char TCHAR
Definition: xmlstorage.h:189
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define MAX_PATH
Definition: compat.h:26
GLsizei const GLfloat * value
Definition: glext.h:6069
#define TEXT(s)
Definition: k32.h:26
static TAGID TAGID find
Definition: db.cpp:153
#define RegQueryValue
Definition: winreg.h:523
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define RegOpenKey
Definition: winreg.h:519
String _classname
Definition: globals.h:38

◆ set_type()

LPCTSTR FileTypeManager::set_type ( struct Entry entry,
bool  dont_hide_ext = false 
)

Definition at line 213 of file explorer.cpp.

214 {
215  LPCTSTR ext = _tcsrchr(entry->_data.cFileName, TEXT('.'));
216 
217  if (ext) {
218  const FileTypeInfo& type = (*this)[ext];
219 
220  if (!type._displayname.empty())
221  entry->_type_name = _tcsdup(type._displayname);
222 
223  // hide some file extensions
224  if (type._neverShowExt && !dont_hide_ext) {
225  int len = ext - entry->_data.cFileName;
226 
227  if (entry->_display_name != entry->_data.cFileName)
228  free(entry->_display_name);
229 
230  entry->_display_name = (LPTSTR) malloc((len+1)*sizeof(TCHAR));
231  lstrcpyn(entry->_display_name, entry->_data.cFileName, len + 1);
232  }
233 
234  if (is_exe_file(ext))
235  entry->_data.dwFileAttributes |= ATTRIBUTE_EXECUTABLE;
236  }
237 
238  return ext;
239 }
#define ATTRIBUTE_EXECUTABLE
Definition: entries.h:63
management of file types
Definition: globals.h:37
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define free
Definition: debug_ros.c:5
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define _tcsdup
Definition: tchar.h:625
CHAR * LPTSTR
Definition: xmlstorage.h:192
static bool is_exe_file(LPCTSTR ext)
Definition: explorer.cpp:150
char ext[3]
Definition: mkdosfs.c:358
char TCHAR
Definition: xmlstorage.h:189
uint32_t entry
Definition: isohybrid.c:63
GLenum GLsizei len
Definition: glext.h:6722
#define TEXT(s)
Definition: k32.h:26
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
#define malloc
Definition: debug_ros.c:4
#define lstrcpyn
Definition: winbase.h:3715

Referenced by WinDirectory::read_directory(), and ShellDirectory::read_directory().


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