luna-sysmgr-common
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Utils.cpp File Reference
#include "Common.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <glib.h>
#include <cjson/json.h>
#include <cjson/json_util.h>
#include <algorithm>
#include <fcntl.h>
#include <QFile>
#include <QByteArray>
#include <QtDebug>
#include "Utils.h"
Include dependency graph for Utils.cpp:

Macros

#define RDBUFFSIZE   (1024*32)
 
#define DUPFD(ofd, nfd)   (dup2(ofd, nfd) == 0 && close(ofd) == 0)
 

Functions

void setPosTopLeft (QGraphicsItem *item, int x, int y)
 
char * readFile (const char *filePath)
 
bool writeFile (const std::string &filePath, const std::string &buffer)
 
bool writeFile (const std::string &filePath, QByteArray buffer)
 
bool writeToTempFile (const std::string &data, const std::string &tempDir, std::string &r_outputFile)
 
bool concatToTempFile (std::vector< std::string > &files, const std::string &tempDir, std::string &r_outputFile)
 
bool deleteFile (const char *filePath)
 
time_t localTime ()
 
unsigned long currentTimeMs ()
 
std::string getResourceNameFromUrl (const QUrl &url)
 
std::string trimWhitespace (const std::string &s, const std::string &drop)
 
bool getNthSubstring (unsigned int n, std::string &dest, const std::string &str, const std::string &delims)
 
int splitFileAndPath (const std::string &srcPathAndFile, std::string &pathPart, std::string &filePart)
 
int splitFileAndExtension (const std::string &srcFileAndExt, std::string &filePart, std::string &extensionPart)
 
int splitStringOnKey (std::vector< std::string > &returnSplitSubstrings, const std::string &baseStr, const std::string &delims)
 
int remap_stdx_pipes (int readPipe, int writePipe)
 
bool isNonErrorProcExit (int ecode, int normalCode)
 
std::string windowIdentifierFromAppAndProcessId (const std::string &appId, const std::string &processId)
 
bool splitWindowIdentifierToAppAndProcessId (const std::string &id, std::string &appId, std::string &processId)
 
std::string getHtml5DatabaseFolderNameForApp (const std::string &appId, std::string appFolderPath)
 
void _malloc_thread_cleanup (void) __attribute__((weak))
 
void threadCleanup ()
 
bool extractFromJson (const std::string &jsonString, const std::string &key, std::string &r_value)
 
bool extractFromJson (struct json_object *root, const std::string &key, std::string &r_value)
 
bool extractFromJson (struct json_object *root, const std::string &key, int &r_value)
 
bool extractFromJson (struct json_object *root, const std::string &key, bool &r_value)
 
struct json_object * JsonGetObject (struct json_object *root, const std::string &key)
 
std::string base64_encode (unsigned char const *bytes_to_encode, unsigned int in_len)
 
std::string base64_decode (std::string const &encoded)
 
bool doesExistOnFilesystem (const char *pathAndFile)
 
int fileCopy (const char *srcFileAndPath, const char *dstFileAndPath)
 
gboolean compare_regex (const gchar *regex, const gchar *string)
 
int determineEnclosingDir (const std::string &fileNameAndPath, std::string &r_enclosingDir)
 
std::string string_printf (const char *format,...)
 
std::string & append_format (std::string &str, const char *format,...)
 

Macro Definition Documentation

#define DUPFD (   ofd,
  nfd 
)    (dup2(ofd, nfd) == 0 && close(ofd) == 0)
#define RDBUFFSIZE   (1024*32)

Function Documentation

void _malloc_thread_cleanup ( void  )
std::string& append_format ( std::string &  str,
const char *  format,
  ... 
)
std::string base64_decode ( std::string const &  encoded)
std::string base64_encode ( unsigned char const *  bytes_to_encode,
unsigned int  in_len 
)
gboolean compare_regex ( const gchar *  regex,
const gchar *  string 
)
bool concatToTempFile ( std::vector< std::string > &  files,
const std::string &  tempDir,
std::string &  r_outputFile 
)
unsigned long currentTimeMs ( )
bool deleteFile ( const char *  filePath)
int determineEnclosingDir ( const std::string &  fileNameAndPath,
std::string &  r_enclosingDir 
)
bool doesExistOnFilesystem ( const char *  pathAndFile)
bool extractFromJson ( const std::string &  jsonString,
const std::string &  key,
std::string &  r_value 
)
bool extractFromJson ( struct json_object *  root,
const std::string &  key,
std::string &  r_value 
)
bool extractFromJson ( struct json_object *  root,
const std::string &  key,
int &  r_value 
)
bool extractFromJson ( struct json_object *  root,
const std::string &  key,
bool &  r_value 
)
int fileCopy ( const char *  srcFileAndPath,
const char *  dstFileAndPath 
)
std::string getHtml5DatabaseFolderNameForApp ( const std::string &  appId,
std::string  appFolderPath 
)
bool getNthSubstring ( unsigned int  n,
std::string &  dest,
const std::string &  str,
const std::string &  delims 
)
std::string getResourceNameFromUrl ( const QUrl &  url)
bool isNonErrorProcExit ( int  ecode,
int  normalCode 
)
struct json_object* JsonGetObject ( struct json_object *  root,
const std::string &  key 
)
read
time_t localTime ( )
char* readFile ( const char *  filePath)
int remap_stdx_pipes ( int  readPipe,
int  writePipe 
)
void setPosTopLeft ( QGraphicsItem *  item,
int  x,
int  y 
)
int splitFileAndExtension ( const std::string &  srcFileAndExt,
std::string &  filePart,
std::string &  extensionPart 
)
int splitFileAndPath ( const std::string &  srcPathAndFile,
std::string &  pathPart,
std::string &  filePart 
)
int splitStringOnKey ( std::vector< std::string > &  returnSplitSubstrings,
const std::string &  baseStr,
const std::string &  delims 
)
bool splitWindowIdentifierToAppAndProcessId ( const std::string &  id,
std::string &  appId,
std::string &  processId 
)
std::string string_printf ( const char *  format,
  ... 
)
void threadCleanup ( )
std::string trimWhitespace ( const std::string &  s,
const std::string &  drop 
)
std::string windowIdentifierFromAppAndProcessId ( const std::string &  appId,
const std::string &  processId 
)
bool writeFile ( const std::string &  filePath,
const std::string &  buffer 
)
bool writeFile ( const std::string &  filePath,
QByteArray  buffer 
)
bool writeToTempFile ( const std::string &  data,
const std::string &  tempDir,
std::string &  r_outputFile 
)