--- a/javacommons/utils/src/javacommonutils.cpp Tue Jul 06 14:10:26 2010 +0300
+++ b/javacommons/utils/src/javacommonutils.cpp Wed Aug 18 09:43:15 2010 +0300
@@ -15,9 +15,11 @@
*
*/
-
+#include <errno.h>
+#include <fcntl.h>
#include <iostream>
#include <sstream>
+#include <unistd.h>
#include <vector>
#include <string.h>
@@ -33,6 +35,16 @@
using namespace java::util;
+// In Symbian working directory should be initalized to C:\private\<UID> by OpenC
+// But for some reason this does not seem to work if process binary is in rom.
+#ifdef __SYMBIAN32__
+const char* const FIRST_BOOT_FILE = "c:\\private\\102033E6\\first_boot_done.dat";
+#else
+const char* const FIRST_BOOT_FILE = "first_boot_done.dat";
+#endif /* __SYMBIAN32__ */
+
+bool JavaCommonUtils::mFirstBoot = false;
+
OS_EXPORT int JavaCommonUtils::stringToInt(const std::string& str)
{
// JELOG2(EUtils);
@@ -372,6 +384,40 @@
}
+OS_EXPORT int JavaCommonUtils::initIsFirstBoot()
+{
+ struct stat fileStatBuf;
+ if (stat(FIRST_BOOT_FILE, &fileStatBuf) == 0)
+ {
+ mFirstBoot = false;
+ }
+ else
+ {
+ mFirstBoot = true;
+
+ // Create flag file so that next time we detect that first boot
+ // has already been done
+ int fd = open(FIRST_BOOT_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
+ if (fd < 0)
+ {
+ return errno;
+ }
+ else
+ {
+ close(fd);
+ }
+ }
+
+ return 0;
+}
+
+
+OS_EXPORT bool JavaCommonUtils::isFirstBoot()
+{
+ return mFirstBoot;
+}
+
+
char JavaCommonUtils::decodeOnePercentSeq(wchar_t first, wchar_t sec)
{
// Handle one encoded %XY