2 * Copyright (C) 2005 Casper S. Hornstrup
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 WineResource::WineResource ( const Project
& project
,
28 : project ( project
),
33 WineResource::~WineResource ()
38 WineResource::IsSpecFile ( const File
& file
)
40 string extension
= GetExtension ( file
.name
);
41 if ( extension
== ".spec" || extension
== ".SPEC" )
47 WineResource::IsWineModule ( const Module
& module
)
49 const vector
<File
*>& files
= module
.non_if_data
.files
;
50 for ( size_t i
= 0; i
< files
.size (); i
++ )
52 if ( IsSpecFile ( *files
[i
] ) )
59 WineResource::IsResourceFile ( const File
& file
)
61 string extension
= GetExtension ( file
.name
);
62 if ( extension
== ".rc" || extension
== ".RC" )
68 WineResource::GetResourceFilename ( const Module
& module
)
70 const vector
<File
*>& files
= module
.non_if_data
.files
;
71 for ( size_t i
= 0; i
< files
.size (); i
++ )
73 if ( IsResourceFile ( *files
[i
] ) )
74 return files
[i
]->name
;
80 WineResource::UnpackResources ( bool verbose
)
82 for ( size_t i
= 0; i
< project
.modules
.size (); i
++ )
84 if ( IsWineModule ( *project
.modules
[i
] ) )
86 UnpackResourcesInModule ( *project
.modules
[i
],
93 WineResource::UnpackResourcesInModule ( Module
& module
,
96 string resourceFilename
= GetResourceFilename ( module
);
97 if ( resourceFilename
.length () == 0 )
102 printf ( "\nUnpacking resources for %s",
103 module
.name
.c_str () );
106 string outputDirectory
= module
.GetBasePath ();
107 string parameters
= ssprintf ( "-b %s -f -x %s",
108 NormalizeFilename ( outputDirectory
).c_str (),
109 NormalizeFilename ( resourceFilename
).c_str () );
110 string command
= bin2res
+ " " + parameters
;
111 int exitcode
= system ( command
.c_str () );
114 throw InvocationFailedException ( command
,