X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Ftracefile.c;h=0af8976a170b4f6537f5139d63c4bb5e33950b67;hb=9f797243e1537f470b67cd27ff2030bfd2d89bcb;hp=d752962acc61b1864b030e767a4315cf7e5663d7;hpb=9d6cdb7be95c430c6ad61ffc7bff0f0942c95b71;p=lttv.git diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index d752962a..0af8976a 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -367,6 +367,27 @@ void getCpuFileInfo(LttTrace *t, char* cpu) *are released as well. ****************************************************************************/ +void get_absolute_pathname(const char *pathname, char * abs_pathname) +{ + char * ptr, *ptr1; + size_t size = DIR_NAME_SIZE; + abs_pathname[0] = '\0'; + if(!getcwd(abs_pathname, size)){ + g_warning("Can not get current working directory\n"); + strcat(abs_pathname, pathname); + return; + } + strcat(abs_pathname,"/"); + + ptr = (char*)pathname; + ptr1 = ptr + 1; + while(*ptr == '.' && *ptr1 == '.'){ + ptr += 3; + ptr1 = ptr + 1; + } + strcat(abs_pathname,ptr); +} + LttTrace *ltt_trace_open(const char *pathname) { LttTrace * t; @@ -376,30 +397,33 @@ LttTrace *ltt_trace_open(const char *pathname) char control[DIR_NAME_SIZE]; char cpu[DIR_NAME_SIZE]; char tmp[DIR_NAME_SIZE]; + char abs_path[DIR_NAME_SIZE]; gboolean has_slash = FALSE; + get_absolute_pathname(pathname, abs_path); + //establish the pathname to different directories - if(pathname[strlen(pathname)-1] == '/')has_slash = TRUE; - strcpy(eventdefs,pathname); + if(abs_path[strlen(abs_path)-1] == '/')has_slash = TRUE; + strcpy(eventdefs,abs_path); if(!has_slash)strcat(eventdefs,"/"); strcat(eventdefs,"eventdefs/"); - strcpy(info,pathname); + strcpy(info,abs_path); if(!has_slash)strcat(info,"/"); strcat(info,"info/"); - strcpy(control,pathname); + strcpy(control,abs_path); if(!has_slash)strcat(control,"/"); strcat(control,"control/"); - strcpy(cpu,pathname); + strcpy(cpu,abs_path); if(!has_slash)strcat(cpu,"/"); strcat(cpu,"cpu/"); //new trace t = g_new(LttTrace, 1); sys_description = g_new(LttSystemDescription, 1); - t->pathname = g_strdup(pathname); + t->pathname = g_strdup(abs_path); t->facility_number = 0; t->control_tracefile_number = 0; t->per_cpu_tracefile_number = 0;