ReactOS 0.4.15-dev-7931-gfd331f1
del.c File Reference
#include "precomp.h"
Include dependency graph for del.c:

Go to the source code of this file.

Macros

#define BufferSize   65536
 

Enumerations

enum  {
  DEL_ATTRIBUTES = 0x001 , DEL_NOTHING = 0x004 , DEL_PROMPT = 0x008 , DEL_QUIET = 0x010 ,
  DEL_SUBDIR = 0x020 , DEL_TOTAL = 0x040 , DEL_WIPE = 0x080 , DEL_EMPTYDIR = 0x100 ,
  DEL_YES = 0x200 , DEL_FORCE = 0x800
}
 
enum  {
  ATTR_ARCHIVE = 0x001 , ATTR_HIDDEN = 0x002 , ATTR_SYSTEM = 0x004 , ATTR_READ_ONLY = 0x008 ,
  ATTR_N_ARCHIVE = 0x010 , ATTR_N_HIDDEN = 0x020 , ATTR_N_SYSTEM = 0x040 , ATTR_N_READ_ONLY = 0x080
}
 

Functions

static VOID LoadStrings (VOID)
 
static BOOL RemoveFile (LPTSTR lpFileName, DWORD dwFlags, WIN32_FIND_DATA *f)
 
static DWORD DeleteFiles (LPTSTR FileName, DWORD *dwFlags, DWORD dwAttrFlags)
 
static DWORD ProcessDirectory (LPTSTR FileName, DWORD *dwFlags, DWORD dwAttrFlags)
 
INT CommandDelete (LPTSTR param)
 

Variables

static TCHAR szDeleteWipe [RC_STRING_MAX_SIZE]
 
static TCHAR CMDPath [MAX_PATH]
 
static BOOLEAN StringsLoaded = FALSE
 

Macro Definition Documentation

◆ BufferSize

_In_ WDFMEMORY _Out_opt_ size_t * BufferSize   65536

Definition at line 75 of file mmc.h.

Referenced by __GetLocaleInfoUsingACP(), _At_(), _Locale_ctype_create(), _Locale_monetary_create(), _Locale_numeric_create(), A_SHAUpdate(), AcpiRsGetListLength(), AddGenericHeaderIPv4(), AhciZeroMemory(), FxUsbDeviceStringContext::AllocateDescriptor(), BaseQuerySystemFirmware(), BlMmAllocateHeap(), BlockIopOperation(), BuildWindowStationNameList(), CallNt(), CheckReadPipe(), CheckWritePipe(), CopyHostentToBuffer(), CopyProtoentToBuffer(), CopyServentToBuffer(), CsrAllocateCaptureBuffer(), DECLARE_INTERFACE_(), DefineDosDeviceW(), DiskGetExtendedDriveParameters(), DispTdiReceiveDatagram(), DispTdiSendDatagram(), DsAddressToSiteNamesA(), DsAddressToSiteNamesExA(), DsAddressToSiteNamesW(), DsEnumerateDomainTrustsA(), DsGetDcNameWithAccountA(), DsGetDcSiteCoverageA(), DsGetDcSiteCoverageW(), EfiLocateHandleBuffer(), ExeFmtpReadFile(), FilterConnectCommunicationPort(), FsRtlpRegisterProviderWithMUP(), GetCurrentExeName(), GetDeviceLocationString(), GetDeviceStatusString(), GetDriverProviderString(), GetDriverVersionString(), GetListViewItem(), CWineTest::GetNextTest(), GetProcessImageFileNameA(), GetProcessImageFileNameW(), GetSourcePaths(), GetSystemTimes(), GetVolumeNameForRoot(), GetVolumePathNamesForVolumeNameW(), HalpQueryDriveLayout(), HvpWriteLog(), i8042InitializeHwHacks(), ImgpInitializeBootApplicationParameters(), InfHostOpenBufferedFile(), InfHostWriteFile(), InfOpenBufferedFile(), InfoTdiQueryListEntities(), InfWriteFile(), IniCacheSaveByHandle(), InitCapturePin(), FxNPagedLookasideListFromPool::Initialize(), FxPagedLookasideListFromPool::Initialize(), InitializeCircularBuffer(), InitializeFmIfsOnce(), FxLookasideList::InitializeLookaside(), InstallInfSections(), InternalExplicitAccessAToW(), InternalTrusteeAToW(), IopGetDeviceProperty(), IopGetDeviceRelations(), IopSaveBootLogToFile(), KeyboardDeviceWorker(), KmtFltSendBufferToDriver(), KsiCreateObjectType(), LsaQuerySecret(), LsaRetrievePrivateData(), LsarQuerySecret(), LsaSetSecret(), LsaStorePrivateData(), main(), MesBufferHandleReset(), MesDecodeBufferHandleCreate(), MesEncodeFixedBufferHandleCreate(), MiDoMappedCopy(), MiDoPoolCopy(), MMSYS_InstallDevice(), NetEnumerateComputerNames(), NetUserModalsGet(), NewDirectSoundNotify(), NpReadDataQueue(), NpWaitPipe(), NpWriteDataQueue(), NtCreateProfile(), NtGdiGetCharABCWidthsW(), NtGdiGetCharWidthW(), NtNotifyChangeDirectoryFile(), ParaNdis_SetMulticastList(), PeekNamedPipe(), PerfDataRefresh(), PrimaryDirectSoundBuffer_Write(), PrintAllVCNs(), RegEnumKeyExW(), RemoveFile(), RtlAddAttributeActionToRXact(), RtlQueryRegistryValues(), ScmConvertToBootPathName(), SeCaptureLuidAndAttributesArray(), FxRequestMemory::SetBuffer(), FxRequestMemory::SetMdl(), SharedMem_Create(), ShellShutdownDialog(), START_TEST(), state_panic(), TdiQueryAddress(), Test_IoSetDeviceInterface(), Test_RtlUnicodeStringPrintf(), Test_RtlUnicodeStringPrintfEx(), CPortPinDMus::TransferMidiData(), CPortPinDMus::TransferMidiDataToDMus(), FxMemoryBufferPreallocated::UpdateBuffer(), CPortPinWaveCyclic::UpdateCommonBuffer(), CPortPinWaveCyclic::UpdateCommonBufferOverlap(), UpdateDriverForPlugAndPlayDevicesW(), VidBiosClearScreen(), VideoAllocateOffScreenBuffer(), VTUTF8ChannelIWrite(), WCacheAllocAsyncEntry(), WinLdrGetNLSNames(), WinLdrInitErrataInf(), WritePartitions(), CConsole::WriteString(), WSPGetSockOpt(), xHalExamineMBR(), xHalIoSetPartitionInformation(), and xHalIoWritePartitionTable().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DEL_ATTRIBUTES 
DEL_NOTHING 
DEL_PROMPT 
DEL_QUIET 
DEL_SUBDIR 
DEL_TOTAL 
DEL_WIPE 
DEL_EMPTYDIR 
DEL_YES 
DEL_FORCE 

Definition at line 53 of file del.c.

54{
55 DEL_ATTRIBUTES = 0x001, /* /A */
56 DEL_NOTHING = 0x004, /* /N */
57 DEL_PROMPT = 0x008, /* /P */
58 DEL_QUIET = 0x010, /* /Q */
59 DEL_SUBDIR = 0x020, /* /S */
60 DEL_TOTAL = 0x040, /* /T */
61 DEL_WIPE = 0x080, /* /W */
62 DEL_EMPTYDIR = 0x100, /* /X : not implemented */
63 DEL_YES = 0x200, /* /Y */
64 DEL_FORCE = 0x800 /* /F */
65};
@ DEL_PROMPT
Definition: del.c:57
@ DEL_QUIET
Definition: del.c:58
@ DEL_SUBDIR
Definition: del.c:59
@ DEL_EMPTYDIR
Definition: del.c:62
@ DEL_TOTAL
Definition: del.c:60
@ DEL_ATTRIBUTES
Definition: del.c:55
@ DEL_YES
Definition: del.c:63
@ DEL_FORCE
Definition: del.c:64
@ DEL_NOTHING
Definition: del.c:56
@ DEL_WIPE
Definition: del.c:61

◆ anonymous enum

anonymous enum
Enumerator
ATTR_ARCHIVE 
ATTR_HIDDEN 
ATTR_SYSTEM 
ATTR_READ_ONLY 
ATTR_N_ARCHIVE 
ATTR_N_HIDDEN 
ATTR_N_SYSTEM 
ATTR_N_READ_ONLY 

Definition at line 67 of file del.c.

68{
69 ATTR_ARCHIVE = 0x001, /* /A:A */
70 ATTR_HIDDEN = 0x002, /* /A:H */
71 ATTR_SYSTEM = 0x004, /* /A:S */
72 ATTR_READ_ONLY = 0x008, /* /A:R */
73 ATTR_N_ARCHIVE = 0x010, /* /A:-A */
74 ATTR_N_HIDDEN = 0x020, /* /A:-H */
75 ATTR_N_SYSTEM = 0x040, /* /A:-S */
76 ATTR_N_READ_ONLY = 0x080 /* /A:-R */
77};
@ ATTR_SYSTEM
Definition: del.c:71
@ ATTR_N_ARCHIVE
Definition: del.c:73
@ ATTR_N_READ_ONLY
Definition: del.c:76
@ ATTR_READ_ONLY
Definition: del.c:72
@ ATTR_N_SYSTEM
Definition: del.c:75
@ ATTR_HIDDEN
Definition: del.c:70
@ ATTR_N_HIDDEN
Definition: del.c:74
@ ATTR_ARCHIVE
Definition: del.c:69

Function Documentation

◆ CommandDelete()

INT CommandDelete ( LPTSTR  param)

Definition at line 358 of file del.c.

359{
360 /*cmd is the command that was given, in this case it will always be "del" or "delete"
361 param is whatever is given after the command*/
362
363 LPTSTR *arg = NULL;
364 INT args;
365 INT i;
366 INT nEvalArgs = 0; /* number of evaluated arguments */
367 DWORD dwFlags = 0;
368 DWORD dwAttrFlags = 0;
369 DWORD dwFiles = 0;
370 LONG ch;
371 TCHAR szOriginalArg[MAX_PATH];
372
373 /*checks the first two chars of param to see if it is /?
374 this however allows the following command to not show help
375 "del frog.txt /?" */
376
377 if (!StringsLoaded)
378 {
379 LoadStrings();
380 }
381
382 if (!_tcsncmp (param, _T("/?"), 2))
383 {
385 return 0;
386 }
387
388 nErrorLevel = 0;
389
390 arg = split (param, &args, FALSE, FALSE);
391
392 if (args == 0)
393 {
394 /* only command given */
396 freep (arg);
397 return 1;
398 }
399 /* check for options anywhere in command line */
400 for (i = 0; i < args; i++)
401 {
402 if (*arg[i] == _T('/'))
403 {
404 /*found a command, but check to make sure it has something after it*/
405 if (_tcslen (arg[i]) >= 2)
406 {
407 ch = _totupper (arg[i][1]);
408 if (ch == _T('N'))
409 {
411 }
412 else if (ch == _T('P'))
413 {
415 }
416 else if (ch == _T('Q'))
417 {
419 }
420 else if (ch == _T('F'))
421 {
423 }
424 else if (ch == _T('S'))
425 {
427 }
428 else if (ch == _T('T'))
429 {
431 }
432 else if (ch == _T('W'))
433 {
434 dwFlags |= DEL_WIPE;
435 }
436 else if (ch == _T('Y'))
437 {
438 dwFlags |= DEL_YES;
439 }
440 else if (ch == _T('A'))
441 {
443 /*the proper syntax for /A has a min of 4 chars
444 i.e. /A:R or /A:-H */
445 if (_tcslen (arg[i]) < 4)
446 {
448 return 0;
449 }
450 ch = _totupper (arg[i][3]);
451 if (_tcslen (arg[i]) == 4)
452 {
453 if (ch == _T('A'))
454 {
455 dwAttrFlags |= ATTR_ARCHIVE;
456 }
457 if (ch == _T('H'))
458 {
459 dwAttrFlags |= ATTR_HIDDEN;
460 }
461 if (ch == _T('S'))
462 {
463 dwAttrFlags |= ATTR_SYSTEM;
464 }
465 if (ch == _T('R'))
466 {
467 dwAttrFlags |= ATTR_READ_ONLY;
468 }
469 }
470 if (_tcslen (arg[i]) == 5)
471 {
472 if (ch == _T('-'))
473 {
474 ch = _totupper (arg[i][4]);
475 if (ch == _T('A'))
476 {
477 dwAttrFlags |= ATTR_N_ARCHIVE;
478 }
479 if (ch == _T('H'))
480 {
481 dwAttrFlags |= ATTR_N_HIDDEN;
482 }
483 if (ch == _T('S'))
484 {
485 dwAttrFlags |= ATTR_N_SYSTEM;
486 }
487 if (ch == _T('R'))
488 {
489 dwAttrFlags |= ATTR_N_READ_ONLY;
490 }
491 }
492 }
493 }
494 }
495
496 nEvalArgs++;
497 }
498 }
499
500 /* there are only options on the command line --> error!!!
501 there is the same number of args as there is flags, so none of the args were filenames*/
502 if (args == nEvalArgs)
503 {
505 freep (arg);
506 return 1;
507 }
508
509 /* keep quiet within batch files */
510 if (bc != NULL) dwFlags |= DEL_QUIET;
511
512 /* check for filenames anywhere in command line */
513 for (i = 0; i < args && !(dwFiles & 0x80000000); i++)
514 {
515 /*this checks to see if it is a flag; if it isn't, we assume it is a file name*/
516 if ((*arg[i] == _T('/')) || (*arg[i] == _T('-')))
517 continue;
518
519 /* We want to make a copies of the argument */
520 if (_tcslen(arg[i]) == 2 && arg[i][1] == _T(':'))
521 {
522 /* Check for C: D: ... */
523 GetRootPath(arg[i], szOriginalArg, MAX_PATH);
524 }
525 else
526 {
527 _tcscpy(szOriginalArg,arg[i]);
528 }
529 dwFiles += ProcessDirectory(szOriginalArg, &dwFlags, dwAttrFlags);
530 }
531
532 freep (arg);
533
534 /*Based on MS cmd, we only tell what files are being deleted when /S is used */
535 if (dwFlags & DEL_TOTAL)
536 {
537 dwFiles &= 0x7fffffff;
538 if (dwFiles < 2)
539 {
541 }
542 else
543 {
545 }
546 }
547
548 return 0;
549}
PBATCH_CONTEXT bc
Definition: batch.c:67
INT nErrorLevel
Definition: cmd.c:158
INT GetRootPath(IN LPCTSTR InPath, OUT LPTSTR OutPath, IN INT size)
Definition: internal.c:152
VOID error_req_param_missing(VOID)
Definition: error.c:110
VOID error_invalid_parameter_format(PCTSTR s)
Definition: error.c:145
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
Definition: console.c:182
#define ConOutResPrintf(uID,...)
Definition: console.h:47
#define STRING_DEL_HELP3
Definition: resource.h:102
#define STRING_DEL_HELP1
Definition: resource.h:100
#define STRING_DEL_HELP4
Definition: resource.h:103
static VOID freep(LPSTR *p)
Definition: cmdcons.c:98
static LPSTR * split(LPSTR s, LPINT args)
Definition: cmdcons.c:163
static VOID LoadStrings(VOID)
Definition: del.c:84
static DWORD ProcessDirectory(LPTSTR FileName, DWORD *dwFlags, DWORD dwAttrFlags)
Definition: del.c:279
static BOOLEAN StringsLoaded
Definition: del.c:82
#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
unsigned long DWORD
Definition: ntddk_ex.h:95
GLfloat param
Definition: glext.h:5796
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define _tcscpy
Definition: tchar.h:623
#define _tcsncmp
Definition: tchar.h:1428
#define _totupper
Definition: tchar.h:1509
long LONG
Definition: pedump.c:60
#define args
Definition: format.c:66
Definition: match.c:390
int32_t INT
Definition: typedefs.h:58
#define _T(x)
Definition: vfdio.h:22
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define _tcslen
Definition: xmlstorage.h:198

◆ DeleteFiles()

static DWORD DeleteFiles ( LPTSTR  FileName,
DWORD dwFlags,
DWORD  dwAttrFlags 
)
static

Definition at line 151 of file del.c.

152{
153 TCHAR szFullPath[MAX_PATH];
154 TCHAR szFileName[MAX_PATH];
155 LPTSTR pFilePart;
158 BOOL bExclusion;
159 INT res;
160 DWORD dwFiles = 0;
161
162 _tcscpy(szFileName, FileName);
163
164 if (_tcschr (szFileName, _T('*')) == NULL &&
165 IsExistingDirectory (szFileName))
166 {
167 /* If it doesnt have a \ at the end already then on needs to be added */
168 if (szFileName[_tcslen(szFileName) - 1] != _T('\\'))
169 _tcscat (szFileName, _T("\\"));
170 /* Add a wildcard after the \ */
171 _tcscat (szFileName, _T("*"));
172 }
173
174 if (!_tcscmp (szFileName, _T("*")) ||
175 !_tcscmp (szFileName, _T("*.*")) ||
176 (szFileName[_tcslen(szFileName) - 2] == _T('\\') && szFileName[_tcslen(szFileName) - 1] == _T('*')))
177 {
178 /* well, the user wants to delete everything but if they didnt yes DEL_YES, DEL_QUIET, or DEL_PROMPT
179 then we are going to want to make sure that in fact they want to do that. */
180
181 if (!((*dwFlags & DEL_YES) || (*dwFlags & DEL_QUIET) || (*dwFlags & DEL_PROMPT)))
182 {
183 ConOutPrintf (_T("Delete %s, "),szFileName);
185 if ((res == PROMPT_NO) || (res == PROMPT_BREAK))
186 return 0x80000000;
187 if (res == PROMPT_ALL)
188 *dwFlags |= DEL_YES;
189 }
190 }
191
192 GetFullPathName(szFileName,
193 MAX_PATH,
194 szFullPath,
195 &pFilePart);
196
197 hFile = FindFirstFile(szFullPath, &f);
199 {
200 do
201 {
202 bExclusion = FALSE;
203
204 /*if it is going to be excluded by - no need to check attrs*/
205 if (*dwFlags & DEL_ATTRIBUTES && !bExclusion)
206 {
207 /*save if file attr check if user doesnt care about that attr anyways*/
208 if (dwAttrFlags & ATTR_ARCHIVE && !(f.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE))
209 bExclusion = TRUE;
210 if (dwAttrFlags & ATTR_HIDDEN && !(f.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
211 bExclusion = TRUE;
212 if (dwAttrFlags & ATTR_SYSTEM && !(f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
213 bExclusion = TRUE;
214 if (dwAttrFlags & ATTR_READ_ONLY && !(f.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
215 bExclusion = TRUE;
216 if (dwAttrFlags & ATTR_N_ARCHIVE && (f.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE))
217 bExclusion = TRUE;
218 if (dwAttrFlags & ATTR_N_HIDDEN && (f.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
219 bExclusion = TRUE;
220 if (dwAttrFlags & ATTR_N_SYSTEM && (f.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
221 bExclusion = TRUE;
222 if (dwAttrFlags & ATTR_N_READ_ONLY && (f.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
223 bExclusion = TRUE;
224 }
225 if (bExclusion) continue;
226
227 /* ignore directories */
228 if (f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
229
230 _tcscpy (pFilePart, f.cFileName);
231
232 /* We cant delete ourselves */
233 if (!_tcscmp (CMDPath,szFullPath)) continue;
234
235 TRACE("Full filename: %s\n", debugstr_aw(szFullPath));
236
237 /* ask for deleting */
238 if (*dwFlags & DEL_PROMPT)
239 {
241
243
244 if ((res == PROMPT_NO) || (res == PROMPT_BREAK))
245 {
246 nErrorLevel = 0;
247 continue;
248 }
249 }
250
251 /*user cant ask it to be quiet and tell you what it did*/
252 if (!(*dwFlags & DEL_QUIET) && !(*dwFlags & DEL_TOTAL))
253 {
255 }
256
257 /* delete the file */
258 if (*dwFlags & DEL_NOTHING) continue;
259
260 if (RemoveFile (szFullPath, *dwFlags, &f))
261 {
262 dwFiles++;
263 }
264 else
265 {
267// FindClose(hFile);
268// return -1;
269 }
270 }
271 while (FindNextFile (hFile, &f));
273 }
274 else error_sfile_not_found(szFullPath);
275 return dwFiles;
276}
static VOID ErrorMessage(_In_ DWORD dwErrorCode, _In_opt_ PCWSTR pszMsg,...)
Definition: attrib.c:33
BOOL IsExistingDirectory(IN LPCTSTR pszPath)
Definition: misc.c:504
INT FilePromptYNA(UINT)
Definition: misc.c:622
INT FilePromptYN(UINT)
Definition: misc.c:559
#define PROMPT_NO
Definition: cmd.h:330
#define PROMPT_ALL
Definition: cmd.h:332
VOID error_sfile_not_found(PCTSTR s)
Definition: error.c:100
#define PROMPT_BREAK
Definition: cmd.h:333
#define ConOutPrintf(szStr,...)
Definition: console.h:41
#define ConErrResPrintf(uID,...)
Definition: console.h:50
#define debugstr_aw
Definition: precomp.h:43
#define STRING_DEL_ERROR6
Definition: resource.h:41
#define STRING_DEL_HELP2
Definition: resource.h:101
#define STRING_DEL_ERROR7
Definition: resource.h:42
#define STRING_DEL_ERROR5
Definition: resource.h:40
static BOOL RemoveFile(LPTSTR lpFileName, DWORD dwFlags, WIN32_FIND_DATA *f)
Definition: del.c:92
static TCHAR CMDPath[MAX_PATH]
Definition: del.c:80
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint res
Definition: glext.h:9613
GLfloat f
Definition: glext.h:7540
#define _tcscmp
Definition: tchar.h:1424
#define _tcscat
Definition: tchar.h:622
#define _tcschr
Definition: tchar.h:1406
#define f
Definition: ke_i.h:83
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define TRACE(s)
Definition: solgame.cpp:4
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FindNextFile
Definition: winbase.h:3788
#define FindFirstFile
Definition: winbase.h:3782
#define GetFullPathName
Definition: winbase.h:3821

Referenced by ProcessDirectory().

◆ LoadStrings()

static VOID LoadStrings ( VOID  )
static

Definition at line 84 of file del.c.

85{
89}
HANDLE CMD_ModuleHandle
Definition: cmd.c:165
#define STRING_DELETE_WIPE
Definition: resource.h:209
static TCHAR szDeleteWipe[RC_STRING_MAX_SIZE]
Definition: del.c:79
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define GetModuleFileName
Definition: winbase.h:3831
#define LoadString
Definition: winuser.h:5819

Referenced by CommandDelete().

◆ ProcessDirectory()

static DWORD ProcessDirectory ( LPTSTR  FileName,
DWORD dwFlags,
DWORD  dwAttrFlags 
)
static

Definition at line 279 of file del.c.

280{
281 TCHAR szFullPath[MAX_PATH];
282 LPTSTR pFilePart;
283 LPTSTR pSearchPart;
286 DWORD dwFiles = 0;
287
288 /* Get the full path to the file */
290 MAX_PATH,
291 szFullPath,
292 &pFilePart);
293
294 /* Delete all the files in this directory */
295 dwFiles = DeleteFiles(szFullPath, dwFlags, dwAttrFlags);
296 if (dwFiles & 0x80000000)
297 return dwFiles;
298
299 if (*dwFlags & DEL_SUBDIR)
300 {
301 /* Get just the file name */
302 pSearchPart = _T("*");
303 if (!IsExistingDirectory(szFullPath))
304 {
305 pSearchPart = _tcsrchr(FileName, _T('\\'));
306 if (pSearchPart != NULL)
307 pSearchPart++;
308 else
309 pSearchPart = FileName;
310 }
311
312 /* If no wildcard or file was specified and this is a directory, then
313 display all files in it */
314 if (pFilePart == NULL || IsExistingDirectory(szFullPath))
315 {
316 pFilePart = &szFullPath[_tcslen(szFullPath)];
317 if (*(pFilePart-1) != _T('\\'))
318 *pFilePart++ = _T('\\');
319 _tcscpy(pFilePart, _T("*"));
320 }
321 else
322 {
323 /* strip the filename off of it */
324 _tcscpy(pFilePart, _T("*"));
325 }
326
327 /* Enumerate all the sub-directories */
328 hFile = FindFirstFile(szFullPath, &f);
330 {
331 do
332 {
333 if (!(f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
334 !_tcscmp(f.cFileName, _T(".")) ||
335 !_tcscmp(f.cFileName, _T("..")))
336 continue;
337
338 _tcscpy(pFilePart, f.cFileName);
339 _tcscat(pFilePart, _T("\\"));
340 _tcscat(pFilePart, pSearchPart);
341
342 dwFiles +=ProcessDirectory(szFullPath, dwFlags, dwAttrFlags);
343 if (dwFiles & 0x80000000)
344 {
345 break;
346 }
347 }
348 while (FindNextFile (hFile, &f));
350 }
351 }
352
353 return dwFiles;
354}
static DWORD DeleteFiles(LPTSTR FileName, DWORD *dwFlags, DWORD dwAttrFlags)
Definition: del.c:151
struct _FileName FileName
Definition: fatprocs.h:896
#define _tcsrchr
Definition: utility.h:116

Referenced by CommandDelete(), and ProcessDirectory().

◆ RemoveFile()

static BOOL RemoveFile ( LPTSTR  lpFileName,
DWORD  dwFlags,
WIN32_FIND_DATA f 
)
static

Definition at line 92 of file del.c.

93{
94 /*This function is called by CommandDelete and
95 does the actual process of deleting the single
96 file*/
98 return 1;
99
100 /*check to see if it is read only and if this is done based on /A
101 if it is done by file name, access is denied. However, if it is done
102 using the /A switch you must un-read only the file and allow it to be
103 deleted*/
105 {
106 if (f->dwFileAttributes & FILE_ATTRIBUTE_READONLY)
107 {
108 /*setting file to normal, not saving old attrs first
109 because the file is going to be deleted anyways
110 so the only thing that matters is that it isn't
111 read only.*/
113 }
114 }
115
116 if (dwFlags & DEL_WIPE)
117 {
118 HANDLE file;
119 DWORD temp;
120#define BufferSize 65536
122 LONGLONG i;
124
125 FileSize.u.HighPart = f->nFileSizeHigh;
126 FileSize.u.LowPart = f->nFileSizeLow;
127
128 for(i = 0; i < BufferSize; i++)
129 {
130 buffer[i]=rand() % 256;
131 }
134 {
135 for(i = 0; i < (FileSize.QuadPart - BufferSize); i += BufferSize)
136 {
138 ConOutPrintf (_T("%I64d%% %s\r"),(i * (LONGLONG)100)/FileSize.QuadPart,szDeleteWipe);
139 }
141 ConOutPrintf (_T("100%% %s\n"),szDeleteWipe);
143 }
144 }
145
146 return DeleteFile (lpFileName);
147}
BOOL CheckCtrlBreak(INT)
Definition: misc.c:132
#define BREAK_INPUT
Definition: cmd.h:36
#define BufferSize
Definition: mmc.h:75
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
GLuint buffer
Definition: glext.h:5915
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
#define FILE_FLAG_WRITE_THROUGH
Definition: disk.h:47
#define GENERIC_WRITE
Definition: nt_native.h:90
static calc_node_t temp
Definition: rpn_ieee.c:38
Definition: fci.c:127
int64_t LONGLONG
Definition: typedefs.h:68
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2295 u
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_In_ LPCSTR lpFileName
Definition: winbase.h:3071
#define SetFileAttributes
Definition: winbase.h:3909
#define DeleteFile
Definition: winbase.h:3764
#define CreateFile
Definition: winbase.h:3749
unsigned char BYTE
Definition: xxhash.c:193

Referenced by DeleteFiles().

Variable Documentation

◆ CMDPath

TCHAR CMDPath[MAX_PATH]
static

Definition at line 80 of file del.c.

Referenced by DeleteFiles(), and LoadStrings().

◆ StringsLoaded

BOOLEAN StringsLoaded = FALSE
static

Definition at line 82 of file del.c.

Referenced by CommandDelete(), and LoadStrings().

◆ szDeleteWipe

TCHAR szDeleteWipe[RC_STRING_MAX_SIZE]
static

Definition at line 79 of file del.c.

Referenced by LoadStrings(), and RemoveFile().