< prev index next >

src/jdk.jpackage/linux/native/libapplauncher/LinuxPlatform.cpp

Print this page




 110 }
 111 
 112 TString LinuxPlatform::GetModuleFileName() {
 113     ssize_t len = 0;
 114     TString result;
 115     DynamicBuffer<TCHAR> buffer(MAX_PATH);
 116     if (buffer.GetData() == NULL) {
 117         return result;
 118     }
 119 
 120     if ((len = readlink("/proc/self/exe", buffer.GetData(),
 121             MAX_PATH - 1)) != -1) {
 122         buffer[len] = '\0';
 123         result = buffer.GetData();
 124     }
 125 
 126     return result;
 127 }
 128 
 129 void LinuxPlatform::SetCurrentDirectory(TString Value) {
 130     chdir(PlatformString(Value).toPlatformString());
 131 }
 132 
 133 TString LinuxPlatform::GetPackageRootDirectory() {
 134     TString result;
 135     TString filename = GetModuleFileName();
 136     TString binPath = FilePath::ExtractFilePath(filename);
 137 
 138     size_t slash = binPath.find_last_of(TRAILING_PATHSEPARATOR);
 139     if (slash != TString::npos) {
 140         result = binPath.substr(0, slash);
 141     }
 142 
 143     return result;
 144 }
 145 
 146 TString LinuxPlatform::GetAppDataDirectory() {
 147     TString result;
 148     TString home = GetEnv(_T("HOME"));
 149 
 150     if (home.empty() == false) {




 110 }
 111 
 112 TString LinuxPlatform::GetModuleFileName() {
 113     ssize_t len = 0;
 114     TString result;
 115     DynamicBuffer<TCHAR> buffer(MAX_PATH);
 116     if (buffer.GetData() == NULL) {
 117         return result;
 118     }
 119 
 120     if ((len = readlink("/proc/self/exe", buffer.GetData(),
 121             MAX_PATH - 1)) != -1) {
 122         buffer[len] = '\0';
 123         result = buffer.GetData();
 124     }
 125 
 126     return result;
 127 }
 128 
 129 void LinuxPlatform::SetCurrentDirectory(TString Value) {
 130     int ignored = chdir(PlatformString(Value).toPlatformString());
 131 }
 132 
 133 TString LinuxPlatform::GetPackageRootDirectory() {
 134     TString result;
 135     TString filename = GetModuleFileName();
 136     TString binPath = FilePath::ExtractFilePath(filename);
 137 
 138     size_t slash = binPath.find_last_of(TRAILING_PATHSEPARATOR);
 139     if (slash != TString::npos) {
 140         result = binPath.substr(0, slash);
 141     }
 142 
 143     return result;
 144 }
 145 
 146 TString LinuxPlatform::GetAppDataDirectory() {
 147     TString result;
 148     TString home = GetEnv(_T("HOME"));
 149 
 150     if (home.empty() == false) {


< prev index next >