Ignore:
Timestamp:
Sep 20, 2018 3:20:39 AM (20 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
85ebb2f
Parents:
3c0a8cf
Message:

Mac OS X Launcher: more cleanup and some bugfixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/SBridge.h

    r3c0a8cf re8decff5  
    88
    99#import <Foundation/Foundation.h>
     10#import <Cocoa/Cocoa.h>
     11
     12#ifdef __cplusplus
     13#include <memory>
     14#include <future>
     15#include <glob.h>
     16#include <string>
     17#include <vector>
     18#include "include/fn.h"
     19std::future<int> startupRouter(NSString* javaBin, NSArray<NSString*>* arguments, NSString* i2pBaseDir);
     20
     21
     22namespace osx {
     23  inline void openUrl(NSString* url)
     24  {
     25    [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: url]];
     26  }
     27}
     28
     29inline std::vector<std::string> globVector(const std::string& pattern){
     30  glob_t glob_result;
     31  glob(pattern.c_str(),GLOB_TILDE,NULL,&glob_result);
     32  std::vector<std::string> files;
     33  for(unsigned int i=0;i<glob_result.gl_pathc;++i){
     34    files.push_back(std::string(glob_result.gl_pathv[i]));
     35  }
     36  globfree(&glob_result);
     37  return files;
     38}
     39
     40inline std::string buildClassPathForObjC(std::string basePath)
     41{
     42  NSBundle *launcherBundle = [NSBundle mainBundle];
     43  auto jarList = globVector(basePath+std::string("/lib/*.jar"));
     44 
     45  std::string classpathStrHead = "-classpath";
     46  std::string classpathStr = "";
     47  classpathStr += [[launcherBundle pathForResource:@"launcher" ofType:@"jar"] UTF8String];
     48  std::string prefix(basePath);
     49  prefix += "/lib/";
     50  for_each(jarList, [&classpathStr](std::string str){ classpathStr += std::string(":") + str; });
     51  return classpathStr;
     52}
     53
     54#endif
    1055
    1156@interface SBridge : NSObject
Note: See TracChangeset for help on using the changeset viewer.