Contribution for Bug353020
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / parsers / custom / CustomXmlTrace.java
index eb9dc0603bb003796eb1f7dfcbc4ae67c08a9da6..6c60dc4841d5e8094c9db6445f835e7d6953ced7 100644 (file)
@@ -100,8 +100,14 @@ public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> {
     @Override\r
     public TmfContext seekLocation(double ratio) {\r
         try {\r
-            RandomAccessFile raFile = new RandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
-            ITmfLocation<?> location = new TmfLocation<Long>(new Long((long) (ratio * raFile.length())));\r
+            BufferedRandomAccessFile raFile = new BufferedRandomAccessFile(getPath(), "r"); //$NON-NLS-1$\r
+            long pos = (long) (ratio * raFile.length());\r
+            while (pos > 0) {\r
+                raFile.seek(pos - 1);\r
+                if (raFile.read() == '\n') break;\r
+                pos--;\r
+            }\r
+            ITmfLocation<?> location = new TmfLocation<Long>(new Long(pos));\r
             TmfContext context = seekLocation(location);\r
             context.setRank(ITmfContext.UNKNOWN_RANK);\r
             return context;\r
@@ -137,7 +143,8 @@ public class CustomXmlTrace extends TmfTrace<CustomXmlEvent> {
     \r
     @Override\r
     public ITmfLocation<?> getCurrentLocation() {\r
-        return new TmfLocation<Object>(null);\r
+        // TODO Auto-generated method stub\r
+        return null;\r
     }\r
 \r
     @Override\r
This page took 0.027525 seconds and 5 git commands to generate.