Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
841d9828
Commit
841d9828
authored
Feb 25, 2003
by
Eric Pouech
Committed by
Alexandre Julliard
Feb 25, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- made support for paged output a generic feature in wcmd
- rewrote DIR command accordingly
parent
abef9da1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
61 deletions
+56
-61
directory.c
programs/wcmd/directory.c
+13
-56
wcmd.h
programs/wcmd/wcmd.h
+3
-1
wcmdmain.c
programs/wcmd/wcmdmain.c
+40
-4
No files found.
programs/wcmd/directory.c
View file @
841d9828
...
...
@@ -43,9 +43,8 @@ extern int echo_mode;
extern
char
quals
[
MAX_PATH
],
param1
[
MAX_PATH
],
param2
[
MAX_PATH
];
extern
DWORD
errorlevel
;
int
file_total
,
dir_total
,
line_count
,
page_mode
,
recurse
,
wide
,
bare
,
max_width
;
ULONGLONG
byte_total
;
static
int
file_total
,
dir_total
,
recurse
,
wide
,
bare
,
max_width
;
static
ULONGLONG
byte_total
;
/*****************************************************************************
* WCMD_directory
...
...
@@ -54,19 +53,18 @@ ULONGLONG byte_total;
*
*/
void
WCMD_directory
()
{
void
WCMD_directory
(
void
)
{
char
path
[
MAX_PATH
],
drive
[
8
];
int
status
;
int
status
,
paged_mode
;
ULARGE_INTEGER
avail
,
total
,
free
;
CONSOLE_SCREEN_BUFFER_INFO
consoleInfo
;
line_count
=
5
;
byte_total
=
0
;
file_total
=
dir_total
=
0
;
/* Handle args */
page_mode
=
(
strstr
(
quals
,
"/P"
)
!=
NULL
);
page
d
_mode
=
(
strstr
(
quals
,
"/P"
)
!=
NULL
);
recurse
=
(
strstr
(
quals
,
"/S"
)
!=
NULL
);
wide
=
(
strstr
(
quals
,
"/W"
)
!=
NULL
);
bare
=
(
strstr
(
quals
,
"/B"
)
!=
NULL
);
...
...
@@ -78,11 +76,15 @@ CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
GetConsoleScreenBufferInfo
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
&
consoleInfo
);
max_width
=
consoleInfo
.
dwSize
.
X
;
}
if
(
paged_mode
)
{
WCMD_enter_paged_mode
();
}
if
(
param1
[
0
]
==
'\0'
)
strcpy
(
param1
,
"."
);
status
=
GetFullPathName
(
param1
,
sizeof
(
path
),
path
,
NULL
);
if
(
!
status
)
{
WCMD_print_error
();
if
(
paged_mode
)
WCMD_leave_paged_mode
();
return
;
}
lstrcpyn
(
drive
,
path
,
3
);
...
...
@@ -90,6 +92,7 @@ CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
if
(
!
bare
)
{
status
=
WCMD_volume
(
0
,
drive
);
if
(
!
status
)
{
if
(
paged_mode
)
WCMD_leave_paged_mode
();
return
;
}
}
...
...
@@ -108,6 +111,7 @@ CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
WCMD_output
(
" %18s bytes free
\n\n
"
,
WCMD_filesize64
(
free
.
QuadPart
));
}
}
if
(
paged_mode
)
WCMD_leave_paged_mode
();
}
/*****************************************************************************
...
...
@@ -128,12 +132,11 @@ char string[1024], datestring[32], timestring[32];
char
mem_err
[]
=
"Memory Allocation Error"
;
char
*
p
;
char
real_path
[
MAX_PATH
];
DWORD
count
;
WIN32_FIND_DATA
*
fd
;
FILETIME
ft
;
SYSTEMTIME
st
;
HANDLE
hff
;
int
status
,
dir_count
,
file_count
,
entry_count
,
i
,
widest
,
linesout
,
cur_width
,
tmp_width
;
int
status
,
dir_count
,
file_count
,
entry_count
,
i
,
widest
,
cur_width
,
tmp_width
;
ULARGE_INTEGER
byte_count
,
file_size
;
dir_count
=
0
;
...
...
@@ -141,7 +144,6 @@ ULARGE_INTEGER byte_count, file_size;
entry_count
=
0
;
byte_count
.
QuadPart
=
0
;
widest
=
0
;
linesout
=
0
;
cur_width
=
0
;
/*
...
...
@@ -202,14 +204,6 @@ ULARGE_INTEGER byte_count, file_size;
if
(
!
bare
)
{
if
(
level
!=
0
)
WCMD_output
(
"
\n\n
"
);
WCMD_output
(
"Directory of %s
\n\n
"
,
real_path
);
if
(
page_mode
)
{
line_count
+=
2
;
if
(
line_count
>
23
)
{
line_count
=
0
;
WCMD_output
(
anykey
);
ReadFile
(
GetStdHandle
(
STD_INPUT_HANDLE
),
string
,
sizeof
(
string
),
&
count
,
NULL
);
}
}
}
for
(
i
=
0
;
i
<
entry_count
;
i
++
)
{
...
...
@@ -224,9 +218,7 @@ ULARGE_INTEGER byte_count, file_size;
tmp_width
=
cur_width
;
if
((
fd
+
i
)
->
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
{
WCMD_output
(
"["
);
WCMD_output
(
"%s"
,
(
fd
+
i
)
->
cFileName
);
WCMD_output
(
"]"
);
WCMD_output
(
"[%s]"
,
(
fd
+
i
)
->
cFileName
);
dir_count
++
;
tmp_width
=
tmp_width
+
strlen
((
fd
+
i
)
->
cFileName
)
+
2
;
}
else
{
...
...
@@ -247,7 +239,6 @@ ULARGE_INTEGER byte_count, file_size;
if
((
cur_width
+
widest
)
>
max_width
)
{
WCMD_output
(
"
\n
"
);
cur_width
=
0
;
linesout
++
;
}
else
{
WCMD_output
(
"%*.s"
,
(
tmp_width
-
cur_width
)
,
""
);
}
...
...
@@ -258,12 +249,10 @@ ULARGE_INTEGER byte_count, file_size;
if
(
!
bare
)
{
WCMD_output
(
"%10s %8s <DIR> %s
\n
"
,
datestring
,
timestring
,
(
fd
+
i
)
->
cFileName
);
linesout
++
;
}
else
{
if
(
!
((
strcmp
((
fd
+
i
)
->
cFileName
,
"."
)
==
0
)
||
(
strcmp
((
fd
+
i
)
->
cFileName
,
".."
)
==
0
)))
{
WCMD_output
(
"%s%s
\n
"
,
recurse
?
real_path
:
""
,
(
fd
+
i
)
->
cFileName
);
linesout
++
;
}
}
}
...
...
@@ -281,32 +270,14 @@ ULARGE_INTEGER byte_count, file_size;
WCMD_output
(
"%10s %8s %10s %s
\n
"
,
datestring
,
timestring
,
WCMD_filesize64
(
file_size
.
QuadPart
),
(
fd
+
i
)
->
cFileName
);
linesout
++
;
}
else
{
WCMD_output
(
"%s%s
\n
"
,
recurse
?
real_path
:
""
,
(
fd
+
i
)
->
cFileName
);
linesout
++
;
}
}
if
(
page_mode
)
{
line_count
=
line_count
+
linesout
;
linesout
=
0
;
if
(
line_count
>
23
)
{
line_count
=
0
;
WCMD_output
(
anykey
);
ReadFile
(
GetStdHandle
(
STD_INPUT_HANDLE
),
string
,
sizeof
(
string
),
&
count
,
NULL
);
}
}
}
if
(
wide
&&
cur_width
>
0
)
{
WCMD_output
(
"
\n
"
);
if
(
page_mode
)
{
if
(
++
line_count
>
23
)
{
line_count
=
0
;
WCMD_output
(
anykey
);
ReadFile
(
GetStdHandle
(
STD_INPUT_HANDLE
),
string
,
sizeof
(
string
),
&
count
,
NULL
);
}
}
}
if
(
!
bare
)
{
...
...
@@ -316,13 +287,6 @@ ULARGE_INTEGER byte_count, file_size;
else
{
WCMD_output
(
"%8d files %24s bytes
\n
"
,
file_count
,
WCMD_filesize64
(
byte_count
.
QuadPart
));
}
if
(
page_mode
)
{
if
(
++
line_count
>
23
)
{
line_count
=
0
;
WCMD_output
(
anykey
);
ReadFile
(
GetStdHandle
(
STD_INPUT_HANDLE
),
string
,
sizeof
(
string
),
&
count
,
NULL
);
}
}
}
byte_total
=
byte_total
+
byte_count
.
QuadPart
;
file_total
=
file_total
+
file_count
;
...
...
@@ -331,13 +295,6 @@ ULARGE_INTEGER byte_count, file_size;
if
(
!
bare
)
{
if
(
dir_count
==
1
)
WCMD_output
(
"1 directory "
);
else
WCMD_output
(
"%8d directories"
,
dir_count
);
if
(
page_mode
)
{
if
(
++
line_count
>
23
)
{
line_count
=
0
;
WCMD_output
(
anykey
);
ReadFile
(
GetStdHandle
(
STD_INPUT_HANDLE
),
string
,
sizeof
(
string
),
&
count
,
NULL
);
}
}
}
for
(
i
=
0
;
i
<
entry_count
;
i
++
)
{
if
((
recurse
)
&&
...
...
programs/wcmd/wcmd.h
View file @
841d9828
...
...
@@ -40,10 +40,12 @@ void WCMD_create_dir (void);
void
WCMD_delete
(
int
recurse
);
void
WCMD_directory
(
void
);
void
WCMD_echo
(
char
*
);
void
WCMD_enter_paged_mode
(
void
);
void
WCMD_for
(
char
*
);
void
WCMD_give_help
(
char
*
command
);
void
WCMD_goto
(
void
);
void
WCMD_if
(
char
*
);
void
WCMD_leave_paged_mode
(
void
);
void
WCMD_move
(
void
);
void
WCMD_output
(
char
*
format
,
...);
void
WCMD_output_asis
(
char
*
message
);
...
...
@@ -52,7 +54,7 @@ void WCMD_pause (void);
void
WCMD_pipe
(
char
*
command
);
void
WCMD_print_error
(
void
);
void
WCMD_process_command
(
char
*
command
);
int
WCMD_read_console
(
char
*
string
,
int
str_len
);
int
WCMD_read_console
(
char
*
string
,
int
str_len
);
void
WCMD_remove_dir
(
void
);
void
WCMD_rename
(
void
);
void
WCMD_run_program
(
char
*
command
);
...
...
programs/wcmd/wcmdmain.c
View file @
841d9828
...
...
@@ -587,12 +587,31 @@ void WCMD_output (char *format, ...) {
va_list
ap
;
char
string
[
1024
];
DWORD
count
;
va_start
(
ap
,
format
);
vsprintf
(
string
,
format
,
ap
);
WriteFile
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
string
,
lstrlen
(
string
),
&
count
,
NULL
);
va_end
(
ap
);
WCMD_output_asis
(
string
);
}
static
int
line_count
;
static
int
max_height
;
static
BOOL
paged_mode
;
void
WCMD_enter_paged_mode
(
void
)
{
CONSOLE_SCREEN_BUFFER_INFO
consoleInfo
;
GetConsoleScreenBufferInfo
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
&
consoleInfo
);
max_height
=
consoleInfo
.
dwSize
.
Y
;
paged_mode
=
TRUE
;
line_count
=
5
;
/* keep 5 lines from previous output */
}
void
WCMD_leave_paged_mode
(
void
)
{
paged_mode
=
FALSE
;
}
/*******************************************************************
...
...
@@ -602,11 +621,28 @@ DWORD count;
void
WCMD_output_asis
(
char
*
message
)
{
DWORD
count
;
WriteFile
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
message
,
lstrlen
(
message
),
&
count
,
NULL
);
char
*
ptr
;
char
string
[
1024
];
if
(
paged_mode
)
{
do
{
if
((
ptr
=
strchr
(
message
,
'\n'
))
!=
NULL
)
ptr
++
;
WriteFile
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
message
,
(
ptr
)
?
ptr
-
message
:
lstrlen
(
message
),
&
count
,
NULL
);
if
(
ptr
)
{
if
(
++
line_count
>=
max_height
-
1
)
{
line_count
=
0
;
WCMD_output_asis
(
anykey
);
ReadFile
(
GetStdHandle
(
STD_INPUT_HANDLE
),
string
,
sizeof
(
string
),
&
count
,
NULL
);
}
}
}
while
((
message
=
ptr
)
!=
NULL
);
}
else
{
WriteFile
(
GetStdHandle
(
STD_OUTPUT_HANDLE
),
message
,
lstrlen
(
message
),
&
count
,
NULL
);
}
}
/***************************************************************************
* WCMD_strtrim_leading_spaces
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment