size_t size = 2*PATH_MAX;
char execPath[size];
- if (Platform::GetExecutablePath(execPath, &size) != 0) {
+ if (uv_exepath(execPath, &size) != 0) {
// as a last ditch effort, fallback on argv[0] ?
process->Set(String::NewSymbol("execPath"), String::New(argv[0]));
} else {
static const char* GetProcessTitle(int *len);
static int GetMemory(size_t *rss, size_t *vsize);
- static int GetExecutablePath(char* buffer, size_t* size);
static int GetCPUInfo(v8::Local<v8::Array> *cpus);
static double GetFreeMemory();
static double GetTotalMemory();
}
-int Platform::GetExecutablePath(char* buffer, size_t* size) {
- *size = readlink("/proc/self/exe", buffer, *size - 1);
- if (*size <= 0) return -1;
- buffer[*size] = '\0';
- return 0;
-}
-
int Platform::GetCPUInfo(Local<Array> *cpus) {
HandleScope scope;
Local<Object> cpuinfo;
#include <mach/task.h>
#include <mach/mach.h>
#include <mach/mach_host.h>
-#include <mach-o/dyld.h> /* _NSGetExecutablePath */
#include <limits.h> /* PATH_MAX */
#include <unistd.h> // sysconf
}
-int Platform::GetExecutablePath(char* buffer, size_t* size) {
- uint32_t usize = *size;
- int result = _NSGetExecutablePath(buffer, &usize);
- if (result) return result;
-
- char *path = new char[2*PATH_MAX];
-
- char *fullpath = realpath(buffer, path);
- if (fullpath == NULL) {
- delete [] path;
- return -1;
- }
- strncpy(buffer, fullpath, *size);
- delete [] fullpath;
- *size = strlen(buffer);
- return 0;
-}
-
int Platform::GetCPUInfo(Local<Array> *cpus) {
Local<Object> cpuinfo;
Local<Object> cputimes;
}
-int Platform::GetExecutablePath(char* buffer, size_t* size) {
- int mib[4];
- mib[0] = CTL_KERN;
- mib[1] = KERN_PROC;
- mib[2] = KERN_PROC_PATHNAME;
- mib[3] = -1;
-
- if (sysctl(mib, 4, buffer, size, NULL, 0) == -1) {
- return -1;
- }
- *size-=1;
- return 0;
-}
-
int Platform::GetCPUInfo(Local<Array> *cpus) {
Local<Object> cpuinfo;
Local<Object> cputimes;
}
-int Platform::GetExecutablePath(char* buffer, size_t* size) {
- *size = readlink("/proc/self/exe", buffer, *size - 1);
- if (*size <= 0) return -1;
- buffer[*size] = '\0';
- return 0;
-}
-
int Platform::GetCPUInfo(Local<Array> *cpus) {
HandleScope scope;
Local<Object> cpuinfo;
return 0;
}
-int OS::GetExecutablePath(char *buffer, size_t* size) {
- *size = 0;
- return -1;
-}
} // namespace node
}
-int Platform::GetExecutablePath(char* buffer, size_t* size) {
- *size = 0;
- return -1;
-}
-
int Platform::GetCPUInfo(Local<Array> *cpus) {
Local<Object> cpuinfo;
Local<Object> cputimes;
}
-int Platform::GetExecutablePath(char* buffer, size_t* size) {
- const char *execname = getexecname();
- if (!execname) return -1;
- if (execname[0] == '/') {
- char *result = strncpy(buffer, execname, *size);
- *size = strlen(result);
- } else {
- char *result = getcwd(buffer, *size);
- if (!result) return -1;
- result = strncat(buffer, "/", *size);
- if (!result) return -1;
- result = strncat(buffer, execname, *size);
- if (!result) return -1;
- *size = strlen(result);
- }
- return 0;
-}
-
-
static Handle<Value> data_named(kstat_named_t *knp) {
Handle<Value> val;
}
-int Platform::GetExecutablePath(char* buffer, size_t* size) {
- *size = 0;
- return -1;
-}
-
-
int Platform::GetCPUInfo(Local<Array> *cpus) {
return -1;
}