Program 3-2 lsW: File Listing and Directory Traversal in Visual Studio .NET

Make QR Code in Visual Studio .NET Program 3-2 lsW: File Listing and Directory Traversal
Program 3-2 lsW: File Listing and Directory Traversal
Encode QR Code In Visual Studio .NET
Using Barcode creation for .NET Control to generate, create QR-Code image in Visual Studio .NET applications.
/* 3 lsW file list command */ /* lsW [options] [files] */ #include "EvryThngh" BOOL TraverseDirectory (LPCTSTR, DWORD, LPBOOL); DWORD FileType (LPWIN32_FIND_DATA); BOOL ProcessItem (LPWIN32_FIND_DATA, DWORD, LPBOOL); int _tmain (int argc, LPTSTR argv []) { BOOL Flags [MAX_OPTIONS], ok = TRUE; TCHAR PathName [MAX_PATH + 1], CurrPath [MAX_PATH + 1]; LPTSTR pSlash, pFileName; int i, FileIndex; FileIndex = Options ( argc, argv, _T ("Rl"), &Flags [0], &Flags [1], NULL); /* "Parse" the search pattern into "parent" and file name */ GetCurrentDirectory (MAX_PATH, CurrPath); /* Save current path */ if (argc < FileIndex + 1) /* No path specified Current dir */ ok = TraverseDirectory (_T ("*"), MAX_OPTIONS, Flags); else for (i = FileIndex; i < argc; i++) { /* Process all paths on the command line */
Denso QR Bar Code Scanner In .NET
Using Barcode decoder for VS .NET Control to read, scan read, scan image in .NET framework applications.
ok = TraverseDirectory (pFileName, MAX_OPTIONS, Flags) && ok; SetCurrentDirectory (CurrPath); /* Restore directory */ } return ok 0 : 1; } static BOOL TraverseDirectory (LPCTSTR PathName, DWORD NumFlags, LPBOOL Flags) /* Traverse a directory; perform ProcessItem for every match */ /* PathName: Relative or absolute pathname to traverse */ { HANDLE SearchHandle; WIN32_FIND_DATA FindData; BOOL Recursive = Flags [0]; DWORD FType, iPass; TCHAR CurrPath [MAX_PATH + 1]; GetCurrentDirectory (MAX_PATH, CurrPath); for (iPass = 1; iPass <= 2; iPass++) { /* Pass 1: List files */ /* Pass 2: Traverse directories (if -R specified) */ SearchHandle = FindFirstFile (PathName, &FindData); do { FType = FileType (&FindData); /* File or directory */ if (iPass == 1) /* List name and attributes */ ProcessItem (&FindData, MAX_OPTIONS, Flags); if (FType == TYPE_DIR && iPass == 2 && Recursive) { /* Process a subdirectory */ _tprintf (_T ("\n%s\\%s:"), CurrPath, FindDatacFileName); /* Prepare to traverse a directory */ SetCurrentDirectory (FindDatacFileName); TraverseDirectory (_T ("*"), NumFlags, Flags); /* Recursive call */ SetCurrentDirectory (_T ("")); } } while (FindNextFile (SearchHandle, &FindData)); FindClose (SearchHandle); } return TRUE; } static BOOL ProcessItem (LPWIN32_FIND_DATA pFileData, DWORD NumFlags, LPBOOL Flags) /* List file or directory attributes */ { const TCHAR FileTypeChar [] = {' ', 'd'}; DWORD FType = FileType (pFileData); BOOL Long = Flags [1]; SYSTEMTIME LastWrite; if (FType != TYPE_FILE && FType != TYPE_DIR) return FALSE; _tprintf (_T ("\n")); if (Long) { /* Was "-1" option used on the command line */ _tprintf (_T ("%c"), FileTypeChar [FType - 1]); _tprintf (_T ("%10d"), pFileData->nFileSizeLow); FileTimeToSystemTime (&(pFileData->ftLastWriteTime),
Encode Barcode In .NET Framework
Using Barcode creator for Visual Studio .NET Control to generate, create bar code image in .NET applications.
&LastWrite); _tprintf (_T (" %02d/%02d/%04d %02d:%02d:%02d"), LastWritewMonth, LastWritewDay, LastWritewYear, LastWritewHour, LastWritewMinute, LastWritewSecond); } _tprintf (_T (" %s"), pFileData->cFileName); return TRUE; } static DWORD FileType (LPWIN32_FIND_DATA pFileData) /* Types supported - TYPE_FILE: file; TYPE_DIR: directory; TYPE_DOT: or directory */ { BOOL IsDir; DWORD FType; FType = TYPE_FILE; IsDir = (pFileData->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; if (IsDir) if (lstrcmp (pFileData->cFileName, _T ("")) == 0 || lstrcmp (pFileData->cFileName, _T ("")) == 0) FType = TYPE_DOT; else FType = TYPE_DIR; return FType; }
Scanning Barcode In .NET
Using Barcode decoder for VS .NET Control to read, scan read, scan image in VS .NET applications.
Example: Setting File Times
Making QR Code In Visual C#.NET
Using Barcode encoder for .NET Control to generate, create QR image in Visual Studio .NET applications.
Program 3-3 implements the UNIX touch command, which changes file access and modifies times to the current value of the system time Exercise 311 enhances touch so that the new file time is a command line option, as with the actual UNIX command
Painting Quick Response Code In .NET Framework
Using Barcode maker for ASP.NET Control to generate, create QR Code 2d barcode image in ASP.NET applications.
Program 3-3 touch: Setting File Times
Paint QR Code ISO/IEC18004 In Visual Basic .NET
Using Barcode creation for VS .NET Control to generate, create QR Code JIS X 0510 image in .NET applications.
/* 3 touch command */ /* touch [options] files */ #include "EvryThngh" int _tmain (int argc, LPTSTR argv []) { SYSTEMTIME SysTime; FILETIME NewFileTime; LPFILETIME pAccessTime = NULL, pModifyTime = NULL; HANDLE hFile; BOOL Flags [MAX_OPTIONS], SetAccessTime, SetModTime, CreateNew; DWORD CreateFlag; int i, FileIndex; FileIndex = Options (argc, argv, _T ("amc"), &Flags [0], &Flags [1], &Flags [2], NULL); SetAccessTime = !Flags [0]; SetModTime = !Flags [1]; CreateNew = !Flags [2]; CreateFlag = CreateNew OPEN_ALWAYS : OPEN_EXISTING; for (i = FileIndex; i < argc; i++) { hFile = CreateFile (argv [i], GENERIC_READ | GENERIC_WRITE, 0, NULL, CreateFlag, FILE_ATTRIBUTE_NORMAL, NULL); GetSystemTime (&SysTime); SystemTimeToFileTime (&SysTime, &NewFileTime); if (SetAccessTime) pAccessTime = &NewFileTime; if (SetModTime) pModifyTime = &NewFileTime; SetFileTime (hFile, NULL, pAccessTime, pModifyTime); CloseHandle (hFile); } return 0; }
Barcode Encoder In Visual Studio .NET
Using Barcode maker for .NET framework Control to generate, create bar code image in Visual Studio .NET applications.
Painting Code 128A In .NET
Using Barcode drawer for VS .NET Control to generate, create USS Code 128 image in .NET applications.
Generating Barcode In .NET
Using Barcode encoder for .NET framework Control to generate, create bar code image in Visual Studio .NET applications.
Bar Code Maker In Java
Using Barcode creation for Java Control to generate, create bar code image in Java applications.
ANSI/AIM Code 128 Recognizer In .NET Framework
Using Barcode scanner for VS .NET Control to read, scan read, scan image in .NET applications.
Paint Data Matrix 2d Barcode In VB.NET
Using Barcode encoder for .NET framework Control to generate, create Data Matrix image in .NET applications.
USS Code 39 Generator In Java
Using Barcode maker for Java Control to generate, create Code 39 Extended image in Java applications.