Esempio n. 1
0
void editor_db_delete (int map_id) {

   char name[100];
  	const char *map_path;

   map_path = roadmap_db_map_path();
   snprintf (name, sizeof(name), "edt%05d.dat", map_id);
   
   if (roadmap_file_exists (map_path, name)) {

      char **files;
      char **cursor;
      char directory[512];
      char full_name[512];

      /* Delete notes wav files */
      /* FIXME this is broken for multiple counties */
      roadmap_path_format (directory, sizeof (directory), roadmap_path_user (), "markers");
      files = roadmap_path_list (directory, ".wav");

      for (cursor = files; *cursor != NULL; ++cursor) {

         roadmap_path_format (full_name, sizeof (full_name), directory, *cursor);
         roadmap_file_remove (NULL, full_name);
      }

      /* Remove the actual editor file */
      roadmap_file_remove (map_path, name);
   }
}
Esempio n. 2
0
static void * rim_load_resources(unsigned int type, unsigned int flags,
      const char *name, int *mem){

	const char * path;
	void *data = NULL;
	static char image_download_path[512];
	if(strstr(name,".bin")){ // this is a downloaded resources
		static BOOL first_time = TRUE;
		if(first_time){
			roadmap_path_format (image_download_path, sizeof (image_download_path), roadmap_path_downloads (), "skins");
			roadmap_path_format (image_download_path, sizeof (image_download_path), image_download_path, "default");
			first_time = FALSE;
		}
		path = image_download_path;
	}else{
		path = roadmap_path_preferred("user");
	}

	switch (type) {
		case RES_BITMAP:
			*mem = 0;
			data = roadmap_canvas_load_image (path, name);
			break;
		case RES_SOUND:
			data = roadmap_sound_load (path, name, mem);
			break;
	}

	return data;

}
Esempio n. 3
0
void tts_db_generate_path( const char* voice_id, TtsPath* db_path )
{
   static char s_voice_id[TTS_VOICE_MAXLEN] = {0};
   static unsigned long counter = 0;
   char path_suffix[TTS_PATH_MAXLEN];
   const EpochTimeMicroSec* time_now = roadmap_time_get_epoch_us( NULL );


   if ( !db_path )
      return;

   // File name
   snprintf( path_suffix, sizeof( path_suffix ), "%s//%s//%lu-%lu-%lu.%s", TTS_DB_FILES_ROOT_DIR, voice_id,
         time_now->epoch_sec, time_now->usec, counter++, TTS_RESULT_FILE_NAME_EXT );
   // Full path
   roadmap_path_format( db_path->path, TTS_PATH_MAXLEN, roadmap_path_tts(), path_suffix );

   if ( strcmp( s_voice_id, voice_id ) ) // Save io time
   {
      char* parent = roadmap_path_parent( db_path->path, NULL );
      strncpy_safe( s_voice_id, voice_id, TTS_VOICE_MAXLEN );
      // Create path if not exists
      roadmap_path_create( parent );
      free( parent );
   }
}
Esempio n. 4
0
static int load_index(int fips, void **base, size_t *size) {

   const char *map_path = roadmap_db_map_path ();
   char name[30];
   char filename[512];
	
   const char *suffix = "index";

   snprintf (name, sizeof (name), "%05d_%s%s", fips, suffix,
         ROADMAP_DATA_TYPE);
	roadmap_path_format (filename, sizeof (filename), map_path, name);

	roadmap_log(ROADMAP_DEBUG,"index filename: %s", filename);
   RoadMapFile file = roadmap_file_open (filename, "r");

   if (!ROADMAP_FILE_IS_VALID(file)) {
      return -1;
   }

   *size = favail(file);
   *base = malloc (*size);

   int res = roadmap_file_read (file, *base, *size);
   roadmap_file_close (file);

   if (res != (int)*size) {
      free (*base);
      return -1;	
   }

   return 0;
}
Esempio n. 5
0
int editor_db_open (int map_id) {

   char name[100];
   const char *map_path;
   char file_name[512];
   int do_read = 0;

   editor_log_push ("editor_db_open");
	
#ifndef IPHONE
   map_path = roadmap_db_map_path();
#else
	map_path = roadmap_path_preferred("maps");
#endif //IPHONE
	
	if (!map_path) {
      editor_log (ROADMAP_ERROR, "Can't find editor path");
      editor_log_pop ();
      return -1;
	}

   snprintf (name, sizeof(name), "edt%05d.dat", map_id);

   roadmap_path_format (file_name, sizeof (file_name), map_path, name);

   if (roadmap_file_exists (map_path, name)) {
      EditorDataFile = roadmap_file_open(file_name, "rw");  
      do_read = 1;
   } else {
      roadmap_path_create (map_path);
      EditorDataFile = roadmap_file_open(file_name, "w");
      roadmap_file_write (EditorDataFile, &DB_SIGNATURE, sizeof (int));
   }

	do {
	   if (!ROADMAP_FILE_IS_VALID(EditorDataFile)) {
	      editor_log (ROADMAP_ERROR, "Can't open/create new database: %s/%s",
	            map_path, name);
	      editor_log_pop ();
	      return -1;
	   }
	
	   if (do_read) {
   		do_read = 0;
	   	if (editor_db_read () == -1) {
	   		editor_db_free ();
	   		//roadmap_messagebox("Error", "Offline data file is currupt: Re-Initializing data");
	   		roadmap_log (ROADMAP_ERROR, "Offline data file is currupt: Re-Initializing data");
	   		roadmap_file_close (EditorDataFile);
	   		roadmap_file_remove (NULL, file_name);
		      EditorDataFile = roadmap_file_open(file_name, "w");
      		roadmap_file_write (EditorDataFile, &DB_SIGNATURE, sizeof (int));
	   	}
	   }
	} while (do_read);

   EditorActiveMap = map_id;
   editor_log_pop ();
   return 0;
}
Esempio n. 6
0
const char *editor_sync_get_export_path (void) {

    static char path[1024];
    static int initialized = 0;

    if (!initialized) {
#ifdef IPHONE
        roadmap_path_format (path, sizeof (path), roadmap_path_preferred("maps"), "queue");
#else
        roadmap_path_format (path, sizeof (path), roadmap_db_map_path (), "queue");
#endif //IPHONE
        roadmap_path_create (path);
        initialized = 1;
    }

    return path;
}
Esempio n. 7
0
void tts_android_provider_init( void )
{
   int i;
   TtsProvider provider;

   roadmap_path_format( sgVoicesPath, TTS_PATH_MAXLEN, roadmap_path_tts(), ANDROID_TTS_PROVIDER_VOICES );
   provider.batch_request_limit = 1;
   provider.provider_name = ANDROID_TTS_PROVIDER;
   provider.storage_type = __tts_db_data_storage__file;
   provider.request_cb = _synth_request;
   provider.voices_cfg = sgVoicesPath;
   provider.prepare_cb = WazeTtsManager_Prepare;
   provider.concurrent_limit = -1;

   // Register the android provider
   tts_register_provider( &provider );

   // Initialize the context pool
   for ( i = 0; i < TTS_ACTIVE_REQUESTS_LIMIT; ++i )
   {
      sgCtxPool[i].busy = FALSE;
      sgCtxPool[i].index = i;
   }
}
Esempio n. 8
0
static void *load_resource (unsigned int type, unsigned int flags,
                            const char *name, int *mem) {

   const char *cursor;
   void *data = NULL;

   if (flags & RES_SKIN) {
#ifndef RIMAPI
      for (cursor = roadmap_path_first ("skin");
            cursor != NULL;
            cursor = roadmap_path_next ("skin", cursor)) {
         switch (type) {
            case RES_BITMAP:
               *mem = 0;

               data = roadmap_canvas_load_image (cursor, name);
               break;
            case RES_SOUND:
               data = roadmap_sound_load (cursor, name, mem);
               break;
#ifdef IPHONE_NATIVE
            case RES_NATIVE_IMAGE:
               *mem = 0;

               data = roadmap_main_load_image (cursor, name);
               break;
#endif
         }
         if (data) break;
      }
#else // RIMAPI
      data = rim_load_resources(type, flags, name, mem);
#endif

   } else {

      const char *user_path = roadmap_path_user ();
      char path[512];
      switch (type) {
         case RES_BITMAP:
            *mem = 0;
            roadmap_path_format (path, sizeof (path), user_path, "icons");
            data = roadmap_canvas_load_image (path, name);
            break;
         case RES_SOUND:
            roadmap_path_format (path, sizeof (path), roadmap_path_downloads(), "sound");
            roadmap_path_format (path, sizeof (path), path, roadmap_prompts_get_name());
            data = roadmap_sound_load (path, name, mem);
            break;
#ifdef IPHONE_NATIVE
         case RES_NATIVE_IMAGE:
            *mem = 0;
            roadmap_path_format (path, sizeof (path), user_path, "icons");
            data = roadmap_main_load_image (path, name);
            break;
#endif
      }
   }

   return data;
}