symbian.cpp raw

   1  
   2  #include <aknutils.h>
   3  #include <e32cmn.h>
   4  #include <e32std.h>
   5  #include <f32file.h>
   6  #include <stdlib.h>
   7  #include <string.h>
   8  
   9  extern "C" {
  10  
  11  int
  12  GC_get_main_symbian_stack_base()
  13  {
  14    TThreadStackInfo aInfo;
  15    TInt err = RThread().StackInfo(aInfo);
  16    if (!err) {
  17      return aInfo.iBase;
  18    } else {
  19      return 0;
  20    }
  21  }
  22  
  23  char *
  24  GC_get_private_path_and_zero_file()
  25  {
  26    // Always on `c:` drive.
  27    RFs fs;
  28    fs.Connect();
  29    fs.CreatePrivatePath(EDriveC);
  30    TFileName path;
  31    fs.PrivatePath(path);
  32    fs.Close();
  33    _LIT(KCDrive, "c:");
  34    path.Insert(0, KCDrive);
  35  
  36    // Convert to `char *`, assume ASCII.
  37    TBuf8<KMaxFileName> path8;
  38    path8.Copy(path);
  39    _LIT8(KZero8, "zero");
  40    path8.Append(KZero8);
  41  
  42    size_t size = path8.Length() + 1;
  43    char *copyChar = static_cast<char *>(malloc(size));
  44    if (copyChar)
  45      memcpy(copyChar, path8.PtrZ(), size);
  46  
  47    // Ownership passed.
  48    return copyChar;
  49  }
  50  
  51  } /* extern "C" */
  52