< prev index next >

src/jdk.incubator.jpackage/windows/native/libapplauncher/WindowsPlatform.cpp

Print this page




 153 TString WindowsPlatform::GetPackageLauncherDirectory() {
 154     return GetPackageRootDirectory();
 155 }
 156 
 157 TString WindowsPlatform::GetPackageRuntimeBinDirectory() {
 158     return FilePath::IncludeTrailingSeparator(GetPackageRootDirectory()) + _T("runtime\\bin");
 159 }
 160 
 161 TCHAR* WindowsPlatform::ConvertStringToFileSystemString(TCHAR* Source,
 162         bool &release) {
 163     // Not Implemented.
 164     return NULL;
 165 }
 166 
 167 TCHAR* WindowsPlatform::ConvertFileSystemStringToString(TCHAR* Source,
 168         bool &release) {
 169     // Not Implemented.
 170     return NULL;
 171 }
 172 
 173 void WindowsPlatform::SetCurrentDirectory(TString Value) {
 174     _wchdir(Value.data());
 175 }
 176 
 177 TString WindowsPlatform::GetPackageRootDirectory() {

 178     TString filename = GetModuleFileName();
 179     return FilePath::ExtractFilePath(filename);
 180 }
 181 
 182 TString WindowsPlatform::GetAppDataDirectory() {
 183     TString result;
 184     TCHAR path[MAX_PATH];
 185 
 186     if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path) == S_OK) {
 187         result = path;
 188     }
 189 
 190     return result;
 191 }
 192 
 193 TString WindowsPlatform::GetAppName() {
 194     TString result = GetModuleFileName();
 195     result = FilePath::ExtractFileName(result);
 196     result = FilePath::ChangeFileExt(result, _T(""));
 197     return result;


 691 bool WindowsProcess::Execute(const TString Application,
 692         const std::vector<TString> Arguments, bool AWait) {
 693     bool result = false;
 694 
 695     if (FRunning == false) {
 696         FRunning = true;
 697 
 698         STARTUPINFO startupInfo;
 699         ZeroMemory(&startupInfo, sizeof (startupInfo));
 700         startupInfo.cb = sizeof (startupInfo);
 701         ZeroMemory(&FProcessInfo, sizeof (FProcessInfo));
 702 
 703         TString command = Application;
 704 
 705         for (std::vector<TString>::const_iterator iterator = Arguments.begin();
 706                 iterator != Arguments.end(); iterator++) {
 707             command += TString(_T(" ")) + *iterator;
 708         }
 709 
 710         if (::CreateProcess(Application.data(), (wchar_t*)command.data(), NULL,
 711                 NULL, FALSE, 0, NULL, NULL, &startupInfo, &FProcessInfo) == FALSE) {

 712             TString message = PlatformString::Format(
 713                     _T("Error: Unable to create process %s"),
 714                     Application.data());
 715             throw Exception(message);
 716         } else {
 717             if (FJob.GetHandle() != NULL) {
 718                 if (::AssignProcessToJobObject(FJob.GetHandle(),
 719                         FProcessInfo.hProcess) == 0) {
 720                     // Failed to assign process to job. It doesn't prevent
 721                     // anything from continuing so continue.
 722                 }
 723             }
 724 
 725             // Wait until child process exits.
 726             if (AWait == true) {
 727                 Wait();
 728                 // Close process and thread handles.
 729                 Cleanup();
 730             }
 731         }




 153 TString WindowsPlatform::GetPackageLauncherDirectory() {
 154     return  GetPackageRootDirectory();
 155 }
 156 
 157 TString WindowsPlatform::GetPackageRuntimeBinDirectory() {
 158     return FilePath::IncludeTrailingSeparator(GetPackageRootDirectory()) + _T("runtime\\bin");
 159 }
 160 
 161 TCHAR* WindowsPlatform::ConvertStringToFileSystemString(TCHAR* Source,
 162         bool &release) {
 163     // Not Implemented.
 164     return NULL;
 165 }
 166 
 167 TCHAR* WindowsPlatform::ConvertFileSystemStringToString(TCHAR* Source,
 168         bool &release) {
 169     // Not Implemented.
 170     return NULL;
 171 }
 172 




 173 TString WindowsPlatform::GetPackageRootDirectory() {
 174     TString result;
 175     TString filename = GetModuleFileName();
 176     return FilePath::ExtractFilePath(filename);
 177 }
 178 
 179 TString WindowsPlatform::GetAppDataDirectory() {
 180     TString result;
 181     TCHAR path[MAX_PATH];
 182 
 183     if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path) == S_OK) {
 184         result = path;
 185     }
 186 
 187     return result;
 188 }
 189 
 190 TString WindowsPlatform::GetAppName() {
 191     TString result = GetModuleFileName();
 192     result = FilePath::ExtractFileName(result);
 193     result = FilePath::ChangeFileExt(result, _T(""));
 194     return result;


 688 bool WindowsProcess::Execute(const TString Application,
 689         const std::vector<TString> Arguments, bool AWait) {
 690     bool result = false;
 691 
 692     if (FRunning == false) {
 693         FRunning = true;
 694 
 695         STARTUPINFO startupInfo;
 696         ZeroMemory(&startupInfo, sizeof (startupInfo));
 697         startupInfo.cb = sizeof (startupInfo);
 698         ZeroMemory(&FProcessInfo, sizeof (FProcessInfo));
 699 
 700         TString command = Application;
 701 
 702         for (std::vector<TString>::const_iterator iterator = Arguments.begin();
 703                 iterator != Arguments.end(); iterator++) {
 704             command += TString(_T(" ")) + *iterator;
 705         }
 706 
 707         if (::CreateProcess(Application.data(), (wchar_t*)command.data(), NULL,
 708                 NULL, FALSE, 0, NULL, NULL, &startupInfo, &FProcessInfo)
 709                 == FALSE) {
 710             TString message = PlatformString::Format(
 711                     _T("Error: Unable to create process %s"),
 712                     Application.data());
 713             throw Exception(message);
 714         } else {
 715             if (FJob.GetHandle() != NULL) {
 716                 if (::AssignProcessToJobObject(FJob.GetHandle(),
 717                         FProcessInfo.hProcess) == 0) {
 718                     // Failed to assign process to job. It doesn't prevent
 719                     // anything from continuing so continue.
 720                 }
 721             }
 722 
 723             // Wait until child process exits.
 724             if (AWait == true) {
 725                 Wait();
 726                 // Close process and thread handles.
 727                 Cleanup();
 728             }
 729         }


< prev index next >