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
ae8b7109
Commit
ae8b7109
authored
Sep 19, 2023
by
Akihiro Sagawa
Committed by
Alexandre Julliard
Sep 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Always outputs leading zeros when listing file time information.
parent
2188e11e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
8 deletions
+114
-8
directory.c
programs/cmd/directory.c
+114
-4
directory.c
programs/cmd/tests/directory.c
+0
-4
No files found.
programs/cmd/directory.c
View file @
ae8b7109
...
...
@@ -41,6 +41,10 @@ typedef enum _DISPLAYORDER
Date
}
DISPLAYORDER
;
#define MAX_DATETIME_FORMAT 80
static
WCHAR
date_format
[
MAX_DATETIME_FORMAT
*
2
];
static
WCHAR
time_format
[
MAX_DATETIME_FORMAT
*
2
];
static
int
file_total
,
dir_total
,
max_width
;
static
ULONGLONG
byte_total
;
static
DISPLAYTIME
dirTime
;
...
...
@@ -345,8 +349,10 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
FileTimeToLocalFileTime
(
&
fd
[
i
].
ftCreationTime
,
&
ft
);
}
FileTimeToSystemTime
(
&
ft
,
&
st
);
GetDateFormatW
(
0
,
DATE_SHORTDATE
,
&
st
,
NULL
,
datestring
,
ARRAY_SIZE
(
datestring
));
GetTimeFormatW
(
0
,
TIME_NOSECONDS
,
&
st
,
NULL
,
timestring
,
ARRAY_SIZE
(
timestring
));
GetDateFormatW
(
LOCALE_USER_DEFAULT
,
0
,
&
st
,
date_format
,
datestring
,
ARRAY_SIZE
(
datestring
));
GetTimeFormatW
(
LOCALE_USER_DEFAULT
,
TIME_NOSECONDS
,
&
st
,
time_format
,
timestring
,
ARRAY_SIZE
(
timestring
));
if
(
wide
)
{
...
...
@@ -375,7 +381,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
dir_count
++
;
if
(
!
bare
)
{
WCMD_output
(
L"%1
!10s! %2!8s! <DIR>
"
,
datestring
,
timestring
);
WCMD_output
(
L"%1
%2 <DIR>
"
,
datestring
,
timestring
);
if
(
shortname
)
WCMD_output
(
L"%1!-13s!"
,
fd
[
i
].
cAlternateFileName
);
if
(
usernames
)
WCMD_output
(
L"%1!-23s!"
,
username
);
WCMD_output
(
L"%1"
,
fd
[
i
].
cFileName
);
...
...
@@ -394,7 +400,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
file_size
.
u
.
HighPart
=
fd
[
i
].
nFileSizeHigh
;
byte_count
.
QuadPart
+=
file_size
.
QuadPart
;
if
(
!
bare
)
{
WCMD_output
(
L"%1
!10s! %2!8s! %3!10s!
"
,
datestring
,
timestring
,
WCMD_output
(
L"%1
%2 %3!14s!
"
,
datestring
,
timestring
,
WCMD_filesize64
(
file_size
.
QuadPart
));
if
(
shortname
)
WCMD_output
(
L"%1!-13s!"
,
fd
[
i
].
cAlternateFileName
);
if
(
usernames
)
WCMD_output
(
L"%1!-23s!"
,
username
);
...
...
@@ -523,6 +529,107 @@ static void WCMD_dir_trailer(const WCHAR *path) {
}
}
/* Get the length of a date/time formatting pattern */
/* copied from dlls/kernelbase/locale.c */
static
int
get_pattern_len
(
const
WCHAR
*
pattern
,
const
WCHAR
*
accept
)
{
int
i
;
if
(
*
pattern
==
'\''
)
{
for
(
i
=
1
;
pattern
[
i
];
i
++
)
{
if
(
pattern
[
i
]
!=
'\''
)
continue
;
if
(
pattern
[
++
i
]
!=
'\''
)
return
i
;
}
return
i
;
}
if
(
!
wcschr
(
accept
,
*
pattern
))
return
1
;
for
(
i
=
1
;
pattern
[
i
];
i
++
)
if
(
pattern
[
i
]
!=
pattern
[
0
])
break
;
return
i
;
}
/* Initialize date format to use abbreviated one with leading zeros */
static
void
init_date_format
(
void
)
{
WCHAR
sys_format
[
MAX_DATETIME_FORMAT
];
int
src_pat_len
,
dst_pat_len
;
const
WCHAR
*
src
;
WCHAR
*
dst
=
date_format
;
GetLocaleInfoW
(
LOCALE_USER_DEFAULT
,
LOCALE_SSHORTDATE
,
sys_format
,
ARRAY_SIZE
(
sys_format
));
for
(
src
=
sys_format
;
*
src
;
src
+=
src_pat_len
,
dst
+=
dst_pat_len
)
{
src_pat_len
=
dst_pat_len
=
get_pattern_len
(
src
,
L"yMd"
);
switch
(
*
src
)
{
case
'\''
:
wmemcpy
(
dst
,
src
,
src_pat_len
);
break
;
case
'd'
:
case
'M'
:
if
(
src_pat_len
==
4
)
/* full name */
dst_pat_len
--
;
/* -> use abbreviated one */
/* fallthrough */
case
'y'
:
if
(
src_pat_len
==
1
)
/* without leading zeros */
dst_pat_len
++
;
/* -> with leading zeros */
wmemset
(
dst
,
*
src
,
dst_pat_len
);
break
;
default:
*
dst
=
*
src
;
break
;
}
}
*
dst
=
'\0'
;
TRACE
(
"date format: %s
\n
"
,
wine_dbgstr_w
(
date_format
));
}
/* Initialize time format to use leading zeros */
static
void
init_time_format
(
void
)
{
WCHAR
sys_format
[
MAX_DATETIME_FORMAT
];
int
src_pat_len
,
dst_pat_len
;
const
WCHAR
*
src
;
WCHAR
*
dst
=
time_format
;
GetLocaleInfoW
(
LOCALE_USER_DEFAULT
,
LOCALE_STIMEFORMAT
,
sys_format
,
ARRAY_SIZE
(
sys_format
));
for
(
src
=
sys_format
;
*
src
;
src
+=
src_pat_len
,
dst
+=
dst_pat_len
)
{
src_pat_len
=
dst_pat_len
=
get_pattern_len
(
src
,
L"Hhmst"
);
switch
(
*
src
)
{
case
'\''
:
wmemcpy
(
dst
,
src
,
src_pat_len
);
break
;
case
'H'
:
case
'h'
:
case
'm'
:
case
's'
:
if
(
src_pat_len
==
1
)
/* without leading zeros */
dst_pat_len
++
;
/* -> with leading zeros */
/* fallthrough */
case
't'
:
wmemset
(
dst
,
*
src
,
dst_pat_len
);
break
;
default:
*
dst
=
*
src
;
break
;
}
}
*
dst
=
'\0'
;
/* seconds portion will be dropped by TIME_NOSECONDS */
TRACE
(
"time format: %s
\n
"
,
wine_dbgstr_w
(
time_format
));
}
/*****************************************************************************
* WCMD_directory
*
...
...
@@ -727,6 +834,9 @@ void WCMD_directory (WCHAR *args)
WCMD_enter_paged_mode
(
NULL
);
}
init_date_format
();
init_time_format
();
argno
=
0
;
argN
=
args
;
GetCurrentDirectoryW
(
MAX_PATH
,
cwd
);
...
...
programs/cmd/tests/directory.c
View file @
ae8b7109
...
...
@@ -163,7 +163,6 @@ static BOOL match_timestamp(const char* line, void *data)
(
!
strncmp
(
ptr
,
"dd"
,
2
)
||
!
strncmp
(
ptr
,
"d"
,
1
)))
{
sprintf
(
pattern
,
"%02hd"
,
param
->
st
.
wDay
);
todo_wine_if
(
strncmp
(
ptr
,
"dd"
,
2
))
ok
(
!!
strstr
(
line
,
pattern
),
"expected day %s, got %s
\n
"
,
pattern
,
wine_dbgstr_a
(
line
));
}
else
...
...
@@ -173,7 +172,6 @@ static BOOL match_timestamp(const char* line, void *data)
(
!
strncmp
(
ptr
,
"MM"
,
2
)
||
!
strncmp
(
ptr
,
"M"
,
1
)))
{
sprintf
(
pattern
,
"%02hd"
,
param
->
st
.
wMonth
);
todo_wine_if
(
strncmp
(
ptr
,
"MM"
,
2
))
ok
(
!!
strstr
(
line
,
pattern
),
"expected month %s, got %s
\n
"
,
pattern
,
wine_dbgstr_a
(
line
));
}
else
...
...
@@ -183,7 +181,6 @@ static BOOL match_timestamp(const char* line, void *data)
if
(
strstr
(
format
,
"h"
)
||
strstr
(
format
,
"H"
))
{
sprintf
(
pattern
,
"%02hd"
,
param
->
st
.
wHour
);
todo_wine_if
(
!
strstr
(
format
,
"hh"
)
&&
!
strstr
(
format
,
"HH"
))
ok
(
!!
strstr
(
line
,
pattern
),
"expected hour %s, got %s
\n
"
,
pattern
,
wine_dbgstr_a
(
line
));
}
else
...
...
@@ -192,7 +189,6 @@ static BOOL match_timestamp(const char* line, void *data)
if
(
strstr
(
format
,
"m"
))
{
sprintf
(
pattern
,
"%02hd"
,
param
->
st
.
wMinute
);
todo_wine_if
(
!
strstr
(
format
,
"mm"
))
ok
(
!!
strstr
(
line
,
pattern
),
"expected minute %s, got %s
\n
"
,
pattern
,
wine_dbgstr_a
(
line
));
}
else
...
...
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