diff -r abc41079b313 -r 59b3b4473dc8 javacommons/utils/src/javacommonutils.cpp --- a/javacommons/utils/src/javacommonutils.cpp Fri Jul 23 12:27:20 2010 +0300 +++ b/javacommons/utils/src/javacommonutils.cpp Thu Aug 05 16:07:57 2010 +0300 @@ -15,9 +15,11 @@ * */ - +#include +#include #include #include +#include #include #include @@ -33,6 +35,16 @@ using namespace java::util; +// In Symbian working directory should be initalized to C:\private\ 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