get output file from command line
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@4308 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
03a887ba35
commit
fae25f96ef
1 changed files with 43 additions and 54 deletions
|
@ -26,67 +26,65 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
int filefound = 0;
|
int filefound = 0;
|
||||||
|
|
||||||
if (argc == 3)
|
if (argc != 4)
|
||||||
{
|
return 1;
|
||||||
|
|
||||||
// Get the full path of the local file
|
// Get the full path of the local file
|
||||||
|
|
||||||
mode = argv[1];
|
mode = argv[1];
|
||||||
filename = argv[2];
|
filename = argv[2];
|
||||||
|
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
GetCurrentDirectory(MAX_PATH, buf);
|
GetCurrentDirectory(MAX_PATH, buf);
|
||||||
filepath = buf;
|
filepath = buf;
|
||||||
|
|
||||||
if ((filename.substr(0, 1).compare("\\") != 0) && (filename.substr(1, 1).compare(":") != 0)) {
|
if ((filename.substr(0, 1).compare("\\") != 0) && (filename.substr(1, 1).compare(":") != 0)) {
|
||||||
|
|
||||||
// Path is relative
|
// Path is relative
|
||||||
|
|
||||||
if (filepath.substr(filepath.length() - 1, 1).compare("\\") != 0)
|
if (filepath.substr(filepath.length() - 1, 1).compare("\\") != 0)
|
||||||
filepath.append("\\");
|
filepath.append("\\");
|
||||||
|
|
||||||
filepath.append(filename);
|
filepath.append(filename);
|
||||||
|
|
||||||
} else if ((filename.substr(0, 1).compare("\\") == 0) && (filename.substr(1, 1).compare("\\") != 0)) {
|
} else if ((filename.substr(0, 1).compare("\\") == 0) && (filename.substr(1, 1).compare("\\") != 0)) {
|
||||||
|
|
||||||
// Path is relative to current root
|
// Path is relative to current root
|
||||||
|
|
||||||
if (filepath.substr(1, 1).compare(":") == 0) {
|
if (filepath.substr(1, 1).compare(":") == 0) {
|
||||||
|
|
||||||
// Standard path
|
// Standard path
|
||||||
|
|
||||||
filepath = filepath.substr(0, filepath.find('\\'));
|
filepath = filepath.substr(0, filepath.find('\\'));
|
||||||
filepath.append(filename);
|
filepath.append(filename);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// UNC path
|
// UNC path
|
||||||
|
|
||||||
filepath = filepath.substr(0, filepath.find('\\', filepath.find('\\', 2) + 1));
|
filepath = filepath.substr(0, filepath.find('\\', filepath.find('\\', 2) + 1));
|
||||||
filepath.append(filename);
|
filepath.append(filename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Absolute path
|
// Absolute path
|
||||||
|
|
||||||
filepath = filename;
|
filepath = filename;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate filename
|
// Validate filename
|
||||||
|
|
||||||
WIN32_FIND_DATA wfd;
|
WIN32_FIND_DATA wfd;
|
||||||
HANDLE hFind = FindFirstFile(filepath.c_str(), &wfd);
|
HANDLE hFind = FindFirstFile(filepath.c_str(), &wfd);
|
||||||
|
|
||||||
if (hFind != INVALID_HANDLE_VALUE)
|
if (hFind != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
filefound = 1;
|
filefound = 1;
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int versionfound = 0;
|
int versionfound = 0;
|
||||||
DWORD low = 0, high = 0;
|
DWORD low = 0, high = 0;
|
||||||
|
@ -172,22 +170,13 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// Write the version to an NSIS header file
|
// Write the version to an NSIS header file
|
||||||
|
|
||||||
char appfile[MAX_PATH];
|
ofstream header(argv[3], ofstream::out);
|
||||||
GetModuleFileName(0, appfile, MAX_PATH);
|
|
||||||
|
|
||||||
string headerfile;
|
|
||||||
headerfile = appfile;
|
|
||||||
headerfile = headerfile.substr(0, headerfile.rfind('\\'));
|
|
||||||
headerfile.append("\\LibraryLocal.nsh");
|
|
||||||
|
|
||||||
ofstream header(headerfile.c_str(), ofstream::out);
|
|
||||||
|
|
||||||
if (header)
|
if (header)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!filefound)
|
if (!filefound)
|
||||||
{
|
{
|
||||||
|
|
||||||
header << "!define LIBRARY_VERSION_FILENOTFOUND" << endl;
|
header << "!define LIBRARY_VERSION_FILENOTFOUND" << endl;
|
||||||
}
|
}
|
||||||
else if (!versionfound)
|
else if (!versionfound)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue