sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/engine/statistic/ReadFile.java
--- a/sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/engine/statistic/ReadFile.java Wed Apr 21 15:14:16 2010 +0300
+++ b/sysperfana/analyzetoolext/com.nokia.s60tools.analyzetool/src/com/nokia/s60tools/analyzetool/engine/statistic/ReadFile.java Wed Apr 21 19:42:48 2010 +0300
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+ * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -18,8 +18,10 @@
package com.nokia.s60tools.analyzetool.engine.statistic;
import java.io.BufferedReader;
+import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.AbstractList;
@@ -34,14 +36,13 @@
public class ReadFile {
/** Parser */
- ParseAnalyzeData parser;
+ private ParseAnalyzeData parser;
/**
* Constructor
*/
public ReadFile()
{
- parser = new ParseAnalyzeData(false, true);
}
@@ -71,8 +72,10 @@
// get input
fis = new FileInputStream(file);
input = new BufferedReader(new InputStreamReader(fis,"UTF-8"));
+ int linebreakSize = lineBreakSize(file); //important to determine file position for deferred callstack reading
// get first line of data file
+ parser = new ParseAnalyzeData(false, true, true, linebreakSize);
String line = null;
// go thru file
while ((line = input.readLine()) != null) {
@@ -126,4 +129,44 @@
parser.finish();
}
+
+ /**
+ * Returns true if callstack reading from file is done
+ * on demand; false if callstacks are made available during parsing
+ * phase.
+ * @return true for deferred callstack reading
+ */
+ public boolean hasDeferredCallstacks(){
+ return parser.hasDeferredCallstacks();
+ }
+
+ /**
+ * Determines the size of line breaks in the given file. File produced on the device-side
+ * should have while Windows files have.
+ * @param aFile the file to check
+ * @return 1 or 2 for size of line break, or 0 if it cannot be determined
+ */
+ private static int lineBreakSize(File aFile){
+ int ret = 0;
+ try {
+ BufferedReader br = new BufferedReader(new FileReader( aFile.getPath() ));
+
+ int ch;
+ int cnt = 0;
+ while ((ch = br.read()) >=0){
+ cnt ++;
+ if (ch == '\r'){
+ ret ++;
+ } else if (ch == '\n'){
+ ret ++;
+ break;
+ }
+ }
+
+ } catch (IOException e) {
+ // do nothing, a return value of 0 will indicate some problem
+ }
+ return ret;
+ }
+
}