ReactOS 0.4.15-dev-8241-g63935f8
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}
int toupper(int c)
Definition: utclib.c:881
static const WCHAR *const ext[]
Definition: module.c:53
GLdouble s
Definition: gl.h:2039
GLfloat GLfloat p
Definition: glext.h:8902
#define TEXT(s)
Definition: k32.h:26
#define d
Definition: ke_i.h:81
#define _MAX_EXT
Definition: utility.h:76
#define lstrcmp
Definition: winbase.h:3872
char TCHAR
Definition: xmlstorage.h:189
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by set_type().

◆ operator[]()

const FileTypeInfo & FileTypeManager::operator[] ( String  ext)

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 RegCloseKey(hKey)
Definition: registry.h:49
static TAGID TAGID find
Definition: db.cpp:155
#define NULL
Definition: types.h:112
#define MAX_PATH
Definition: compat.h:34
GLuint GLuint end
Definition: gl.h:1545
if(dx< 0)
Definition: linetemp.h:194
long LONG
Definition: pedump.c:60
management of file types
Definition: globals.h:37
String _classname
Definition: globals.h:38
bool _neverShowExt
Definition: globals.h:40
String _displayname
Definition: globals.h:39
Definition: pdh_main.c:94
#define RegQueryValueEx
Definition: winreg.h:524
#define RegOpenKey
Definition: winreg.h:519
#define RegQueryValue
Definition: winreg.h:523
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10

◆ 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 free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ATTRIBUTE_EXECUTABLE
Definition: entries.h:63
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLsizei len
Definition: glext.h:6722
#define _tcsdup
Definition: tchar.h:625
uint32_t entry
Definition: isohybrid.c:63
#define _tcsrchr
Definition: utility.h:116
static bool is_exe_file(LPCTSTR ext)
Definition: explorer.cpp:150
#define lstrcpyn
Definition: winbase.h:3875

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


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