ReactOS  0.4.14-dev-845-g8381e29
free.c File Reference
#include "precomp.h"
Include dependency graph for free.c:

Go to the source code of this file.

Functions

static VOID PrintDiskInfo (LPTSTR szDisk)
 
INT CommandFree (LPTSTR param)
 

Function Documentation

◆ CommandFree()

INT CommandFree ( LPTSTR  param)

Definition at line 86 of file free.c.

87 {
88  LPTSTR szParam;
89  TCHAR szDefPath[MAX_PATH];
90  INT argc, i;
91  LPTSTR *arg;
92 
93  if (!_tcsncmp (param, _T("/?"), 2))
94  {
96  return 0;
97  }
98 
99  if (!param || *param == _T('\0'))
100  {
101  GetCurrentDirectory (MAX_PATH, szDefPath);
102  szDefPath[2] = _T('\0');
103  szParam = szDefPath;
104  }
105  else
106  szParam = param;
107 
108  arg = split (szParam, &argc, FALSE, FALSE);
109 
110  for (i = 0; i < argc; i++)
111  PrintDiskInfo (arg[i]);
112 
113  freep (arg);
114 
115  return 0;
116 }
static int argc
Definition: ServiceArgs.c:12
#define TRUE
Definition: types.h:120
void * arg
Definition: msvc.h:10
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
Definition: console.c:182
int32_t INT
Definition: typedefs.h:56
CHAR * LPTSTR
Definition: xmlstorage.h:192
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 GetCurrentDirectory
Definition: winbase.h:3639
static VOID freep(LPSTR *p)
Definition: cmdcons.c:98
#define STRING_FREE_HELP2
Definition: resource.h:131
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:26
static LPSTR * split(LPSTR s, LPINT args)
Definition: cmdcons.c:163
static VOID PrintDiskInfo(LPTSTR szDisk)
Definition: free.c:19
int _tcsncmp(const _TCHAR *s1, const _TCHAR *s2, size_t n)
Definition: tcsncmp.h:9

◆ PrintDiskInfo()

static VOID PrintDiskInfo ( LPTSTR  szDisk)
static

Definition at line 19 of file free.c.

20 {
22  TCHAR szRootPath[4] = _T("A:\\");
23  TCHAR szDrive[2] = _T("A");
24  TCHAR szVolume[64];
25  TCHAR szSerial[10];
26  TCHAR szTotal[40];
27  TCHAR szUsed[40];
28  TCHAR szFree[40];
29  DWORD dwSerial;
30  ULONGLONG uliSize;
31  DWORD dwSecPerCl;
32  DWORD dwBytPerSec;
33  DWORD dwFreeCl;
34  DWORD dwTotCl;
35 
36  if (_tcslen (szDisk) < 2 || szDisk[1] != _T(':'))
37  {
39  return;
40  }
41 
42  szRootPath[0] = szDisk[0];
43  szDrive[0] = _totupper (szRootPath[0]);
44 
45  if (!GetVolumeInformation (szRootPath, szVolume, 64, &dwSerial,
46  NULL, NULL, NULL, 0))
47  {
49  ConErrPrintf(_T("%s %s:\n"), szMsg, szDrive);
50  return;
51  }
52 
53  if (szVolume[0] == _T('\0'))
54  {
55 
57  _tcscpy (szVolume, szMsg);
58  }
59 
60  _stprintf (szSerial,
61  _T("%04X-%04X"),
62  HIWORD(dwSerial),
63  LOWORD(dwSerial));
64 
65  if (!GetDiskFreeSpace (szRootPath, &dwSecPerCl,
66  &dwBytPerSec, &dwFreeCl, &dwTotCl))
67  {
69  ConErrPrintf(_T("%s %s:\n"), szMsg, szDrive);
70  return;
71  }
72 
73  uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwTotCl;
74  ConvertULargeInteger(uliSize, szTotal, 40, TRUE);
75 
76  uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)(dwTotCl - dwFreeCl);
77  ConvertULargeInteger(uliSize, szUsed, 40, TRUE);
78 
79  uliSize = dwSecPerCl * dwBytPerSec * (ULONGLONG)dwFreeCl;
80  ConvertULargeInteger(uliSize, szFree, 40, TRUE);
81 
82  ConOutResPrintf(STRING_FREE_HELP1, szDrive, szVolume, szSerial, szTotal, szUsed, szFree);
83 }
#define TRUE
Definition: types.h:120
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define GetDiskFreeSpace
Definition: winbase.h:3641
#define STRING_FREE_ERROR2
Definition: resource.h:50
#define _totupper
Definition: tchar.h:1509
#define ConErrResPrintf(uID,...)
Definition: console.h:51
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
#define STRING_FREE_HELP1
Definition: resource.h:130
smooth NULL
Definition: ftsmooth.c:416
VOID ConErrPrintf(LPTSTR szFormat,...)
Definition: tee.c:36
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
INT ConvertULargeInteger(ULONGLONG num, LPTSTR des, UINT len, BOOL bPutSeparator)
Definition: cmd.c:188
uint64_t ULONGLONG
Definition: typedefs.h:65
#define ConOutResPrintf(uID,...)
Definition: console.h:48
unsigned long DWORD
Definition: ntddk_ex.h:95
#define _stprintf
Definition: utility.h:124
#define GetVolumeInformation
Definition: winbase.h:3687
HANDLE CMD_ModuleHandle
Definition: cmd.c:164
#define STRING_FREE_ERROR1
Definition: resource.h:49
#define HIWORD(l)
Definition: typedefs.h:246
#define LOWORD(l)
Definition: pedump.c:82
#define LoadString
Definition: winuser.h:5794
#define RC_STRING_MAX_SIZE
Definition: resource.h:3

Referenced by CommandFree().