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
d59538f9
Commit
d59538f9
authored
Mar 12, 2012
by
Christian Costa
Committed by
Alexandre Julliard
Mar 14, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attrib: Make command accept several arguments.
parent
a7692beb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
33 deletions
+40
-33
attrib.c
programs/attrib/attrib.c
+40
-33
No files found.
programs/attrib/attrib.c
View file @
d59538f9
/*
* ATTRIB - Wine-compatible attrib program
*
* Copyright 2010-201
1
Christian Costa
* Copyright 2010-201
2
Christian Costa
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -29,7 +29,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(attrib);
* Load a string from the resource file, handling any error
* Returns string retrieved from resource file
* ========================================================================= */
static
WCHAR
*
ATTRIB_LoadMessage
(
UINT
id
)
{
static
WCHAR
*
ATTRIB_LoadMessage
(
UINT
id
)
{
static
WCHAR
msg
[
MAXSTRING
];
const
WCHAR
failedMsg
[]
=
{
'F'
,
'a'
,
'i'
,
'l'
,
'e'
,
'd'
,
'!'
,
0
};
...
...
@@ -45,8 +46,8 @@ static WCHAR *ATTRIB_LoadMessage(UINT id) {
* and hence required WriteConsoleW to output it, however if file i/o is
* redirected, it needs to be WriteFile'd using OEM (not ANSI) format
* ========================================================================= */
static
int
__cdecl
ATTRIB_wprintf
(
const
WCHAR
*
format
,
...)
{
static
int
__cdecl
ATTRIB_wprintf
(
const
WCHAR
*
format
,
...)
{
static
WCHAR
*
output_bufW
=
NULL
;
static
char
*
output_bufA
=
NULL
;
static
BOOL
toConsole
=
TRUE
;
...
...
@@ -128,43 +129,49 @@ int wmain(int argc, WCHAR *argv[])
WIN32_FIND_DATAW
fd
;
WCHAR
flags
[]
=
{
' '
,
' '
,
' '
,
' '
,
' '
,
' '
,
' '
,
' '
,
'\0'
};
WCHAR
name
[
128
];
WCHAR
*
param
=
argc
>=
2
?
argv
[
1
]
:
NULL
;
DWORD
attrib_set
=
0
;
DWORD
attrib_clear
=
0
;
WCHAR
help_option
[]
=
{
'/'
,
'?'
,
'\0'
};
const
WCHAR
help_option
[]
=
{
'/'
,
'?'
,
'\0'
};
const
WCHAR
slashStarW
[]
=
{
'\\'
,
'*'
,
'\0'
};
int
i
=
1
;
if
(
param
&&
!
strcmpW
(
param
,
help_option
))
{
if
((
argc
>=
2
)
&&
!
strcmpW
(
argv
[
1
],
help_option
))
{
ATTRIB_wprintf
(
ATTRIB_LoadMessage
(
STRING_HELP
));
return
0
;
}
if
(
param
&&
(
param
[
0
]
==
'+'
||
param
[
0
]
==
'-'
))
{
DWORD
attrib
=
0
;
/* FIXME: the real cmd can handle many more than two args; this should be in a loop */
switch
(
param
[
1
])
{
case
'H'
:
case
'h'
:
attrib
|=
FILE_ATTRIBUTE_HIDDEN
;
break
;
case
'S'
:
case
's'
:
attrib
|=
FILE_ATTRIBUTE_SYSTEM
;
break
;
case
'R'
:
case
'r'
:
attrib
|=
FILE_ATTRIBUTE_READONLY
;
break
;
case
'A'
:
case
'a'
:
attrib
|=
FILE_ATTRIBUTE_ARCHIVE
;
break
;
default:
ATTRIB_wprintf
(
ATTRIB_LoadMessage
(
STRING_NYI
));
return
0
;
}
switch
(
param
[
0
])
{
case
'+'
:
attrib_set
=
attrib
;
break
;
case
'-'
:
attrib_clear
=
attrib
;
break
;
/* By default all files from current directory are taken into account */
GetCurrentDirectoryW
(
sizeof
(
name
)
/
sizeof
(
WCHAR
),
name
);
strcatW
(
name
,
slashStarW
);
while
(
i
<
argc
)
{
WCHAR
*
param
=
argv
[
i
++
];
if
((
param
[
0
]
==
'+'
)
||
(
param
[
0
]
==
'-'
))
{
DWORD
attrib
=
0
;
switch
(
param
[
1
])
{
case
'H'
:
case
'h'
:
attrib
|=
FILE_ATTRIBUTE_HIDDEN
;
break
;
case
'S'
:
case
's'
:
attrib
|=
FILE_ATTRIBUTE_SYSTEM
;
break
;
case
'R'
:
case
'r'
:
attrib
|=
FILE_ATTRIBUTE_READONLY
;
break
;
case
'A'
:
case
'a'
:
attrib
|=
FILE_ATTRIBUTE_ARCHIVE
;
break
;
default:
ATTRIB_wprintf
(
ATTRIB_LoadMessage
(
STRING_NYI
));
return
0
;
}
switch
(
param
[
0
])
{
case
'+'
:
attrib_set
=
attrib
;
break
;
case
'-'
:
attrib_clear
=
attrib
;
break
;
}
}
else
if
(
param
[
0
]
==
'/'
)
{
if
(((
param
[
1
]
==
'D'
)
||
(
param
[
1
]
==
'd'
))
&&
!
param
[
2
])
{
WINE_FIXME
(
"Option /D not yet supported
\n
"
);
}
else
if
(((
param
[
1
]
==
'R'
)
||
(
param
[
1
]
==
'r'
))
&&
!
param
[
2
])
{
WINE_FIXME
(
"Option /R not yet supported
\n
"
);
}
else
{
WINE_FIXME
(
"Unrecognize option
\n
"
);
}
}
else
if
(
param
[
0
])
{
strcpyW
(
name
,
param
);
}
param
=
argc
>=
3
?
argv
[
2
]
:
NULL
;
}
if
(
!
param
||
strlenW
(
param
)
==
0
)
{
static
const
WCHAR
slashStarW
[]
=
{
'\\'
,
'*'
,
'\0'
};
GetCurrentDirectoryW
(
sizeof
(
name
)
/
sizeof
(
WCHAR
),
name
);
strcatW
(
name
,
slashStarW
);
}
else
{
strcpyW
(
name
,
param
);
}
hff
=
FindFirstFileW
(
name
,
&
fd
);
...
...
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