+/* This file is part of the Linux Trace Toolkit viewer
+ * Copyright (C) 2003-2004 Xiangxiu Yang
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License Version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
while((entry = readdir(dir)) != NULL){
if(strcmp(entry->d_name,".") != 0 &&
- strcmp(entry->d_name,"..") != 0 ){
+ strcmp(entry->d_name,"..") != 0 &&
+ strcmp(entry->d_name,".svn") != 0){
strcpy(name,cpu);
strcat(name,entry->d_name);
ltt_tracefile_open_cpu(t,name);
*
*When a trace is closed, all the associated facilities, types and fields
*are released as well.
+ *
+ * MD : If pathname is already absolute, we do not add current working
+ * directory to it.
+ *
****************************************************************************/
+void get_absolute_pathname(const char *pathname, char * abs_pathname)
+{
+ char * ptr, *ptr1;
+ size_t size = DIR_NAME_SIZE;
+ abs_pathname[0] = '\0';
+
+ if(pathname[0] == '/')
+ {
+ strcat(abs_pathname, pathname);
+ return;
+ }
+
+ 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;
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;