32 #include "stringutils.h" |
32 #include "stringutils.h" |
33 #include "errors.h" |
33 #include "errors.h" |
34 |
34 |
35 |
35 |
36 // SA SIS files |
36 // SA SIS files |
37 InstallableFile::InstallableFile(const CSISFileDescription& aFdes, const CSISFileData* aFdata, const std::wstring aDrivePath, |
37 InstallableFile::InstallableFile(const CSISFileDescription& aFdes, const CSISFileData* aFdata, const std::wstring aDrivePath, int aInstallingDrive) |
38 int aInstallingDrive, const int aSystemdrive, const bool aGenerateRomStub) |
|
39 : isExecutable(aFdata->IsExecutable()), |
38 : isExecutable(aFdata->IsExecutable()), |
40 isExe(aFdata->IsExe()), |
39 isExe(aFdata->IsExe()), |
41 iSid(aFdata->GetSid()), |
40 iSid(aFdata->GetSid()), |
42 isStub(false), |
41 isStub(false), |
43 iFileDescription(&aFdes), |
42 iFileDescription(&aFdes), |
44 iFileData(aFdata), |
43 iFileData(aFdata), |
45 iTargetFile(aFdes.Target().GetString()), |
44 iTargetFile(aFdes.Target().GetString()), |
46 iLocalTargetFile(aFdes.Target().GetString()) |
45 iLocalTargetFile(aFdes.Target().GetString()) |
47 { |
46 { |
48 // Transforming the file path into lower case to maintain consistency |
|
49 // between Windows and Linux as Linux path is case-sensitive. |
|
50 std::transform(iTargetFile.begin(), iTargetFile.end(), iTargetFile.begin(), tolower); |
|
51 std::transform(iLocalTargetFile.begin(), iLocalTargetFile.end(), iLocalTargetFile.begin(), tolower); |
|
52 |
|
53 // Update the installing file with the actual target drive letter |
47 // Update the installing file with the actual target drive letter |
54 ChangeTargetDrive(aDrivePath, aInstallingDrive, aSystemdrive, aGenerateRomStub); |
48 ChangeTargetDrive(aDrivePath, aInstallingDrive); |
55 |
49 |
56 // warn the user if they are using a winscw emulator binary |
50 // warn the user if they are using a winscw emulator binary |
57 if (aFdata->IsEmulatorExecutable()) |
51 if (aFdata->IsEmulatorExecutable()) |
58 LWARN(iTargetFile.c_str() << L" is an emulator binary!"); |
52 LWARN(iTargetFile << L" is an emulator binary!"); |
59 } |
53 } |
60 |
54 |
61 // PA SIS files |
55 // PA SIS files |
62 InstallableFile::InstallableFile(const CSISFileDescription& aFdes, const std::wstring aDrivePath, |
56 InstallableFile::InstallableFile(const CSISFileDescription& aFdes, const std::wstring aDrivePath, |
63 int aInstallingDrive, const int aSystemdrive, const bool aGenerateRomStub) |
57 int aInstallingDrive) |
64 : isExecutable(false), |
58 : isExecutable(false), |
65 isExe(false), |
59 isExe(false), |
66 iSid(0), |
60 iSid(0), |
67 iFileDescription(&aFdes), |
61 iFileDescription(&aFdes), |
68 iFileData(0), |
62 iFileData(0), |
69 isStub(true), |
63 isStub(true), |
70 iTargetFile(aFdes.Target().GetString()), |
64 iTargetFile(aFdes.Target().GetString()), |
71 iLocalTargetFile(aFdes.Target().GetString()) |
65 iLocalTargetFile(aFdes.Target().GetString()) |
72 { |
66 { |
73 // Transforming the file path into lower case to maintain consistency |
|
74 // between Windows and Linux as Linux path is case-sensitive. |
|
75 std::transform(iTargetFile.begin(), iTargetFile.end(), iTargetFile.begin(), tolower); |
|
76 std::transform(iLocalTargetFile.begin(), iLocalTargetFile.end(), iLocalTargetFile.begin(), tolower); |
|
77 |
|
78 // Update the installing file with the actual target drive letter |
67 // Update the installing file with the actual target drive letter |
79 ChangeTargetDrive(aDrivePath, aInstallingDrive, aSystemdrive, aGenerateRomStub); |
68 ChangeTargetDrive(aDrivePath, aInstallingDrive); |
80 |
69 |
81 // retrieve the file attributes e.g. exe, dll, SID etc. |
70 // retrieve the file attributes e.g. exe, dll, SID etc. |
82 const bool fileExists = FileExists( iLocalTargetFile ); |
71 const bool fileExists = FileExists( iLocalTargetFile ); |
83 |
72 |
84 if ( fileExists ) |
73 if ( fileExists ) |
115 InstallableFile::~InstallableFile() |
104 InstallableFile::~InstallableFile() |
116 { |
105 { |
117 delete iFileData; |
106 delete iFileData; |
118 } |
107 } |
119 |
108 |
120 void InstallableFile::SetTarget(const std::wstring& aTargetFile) |
|
121 { |
|
122 iTargetFile = aTargetFile; |
|
123 } |
|
124 |
109 |
125 void InstallableFile::ChangeTargetDrive(const std::wstring aDrivePath, int aInstallingDrive, |
110 void InstallableFile::ChangeTargetDrive(const std::wstring aDrivePath, int aInstallingDrive) |
126 const int aSystemdrive, const bool aGenerateRomStub) |
|
127 { |
111 { |
128 // get the local path |
112 // get the local path |
129 ConvertToLocalPath(iLocalTargetFile,aDrivePath); |
113 ConvertToLocalPath(iLocalTargetFile,aDrivePath); |
130 #ifdef __TOOLS2_LINUX__ |
|
131 ConvertToForwardSlash(iTargetFile); |
|
132 #endif |
|
133 |
114 |
134 // change the drive letter |
115 // change the drive letter |
135 if (StringUtils::StartsWithDrive(iTargetFile)) |
116 if (StringUtils::StartsWithDrive(iTargetFile)) |
136 { |
117 { |
137 std::wstring target(iTargetFile); |
118 std::wstring target(iTargetFile); |
138 int targetFileDrive = tolower(target[0]); |
119 int targetFileDrive = tolower(target[0]); |
139 if (targetFileDrive != aInstallingDrive) |
120 if (targetFileDrive != aInstallingDrive) |
140 { |
121 { |
141 if((iTargetFile[0] == '$') && !aGenerateRomStub) |
122 iTargetFile[0] = aInstallingDrive; |
142 { |
123 LINFO(L"Disregarding drive selection. Installing " |
143 //Creating tmpTarget so that '$' in iTargetFile is retained and |
124 + target + L" to " + iTargetFile); |
144 //can be used as a marker while File Copy to system drive and |
|
145 //not to LocalTargetPath |
|
146 std::wstring tmpTarget(iTargetFile); |
|
147 tmpTarget[0] = aSystemdrive; |
|
148 |
|
149 LINFO(L"Disregarding drive selection. Installing " |
|
150 << target.c_str() << L" to " << tmpTarget.c_str()); |
|
151 } |
|
152 else |
|
153 { |
|
154 iTargetFile[0] = aInstallingDrive; |
|
155 |
|
156 LINFO(L"Disregarding drive selection. Installing " |
|
157 << target.c_str() << L" to " << iTargetFile.c_str()); |
|
158 } |
|
159 } |
125 } |
160 } |
126 } |
161 else |
127 else |
162 { |
128 { |
163 std::wstring error = L"Invalid target file " + iTargetFile; |
129 std::wstring error = L"Invalid target file " + iTargetFile; |