emscripten Humble Cloud interface
Edward Rudd
2014-08-21 374e4b0e261ccd2e22c19a9fb63e7cfecc4bfa92
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
 
#include <emscripten/emscripten.h>
 
#include "humble_api.h"
 
#include <dirent.h>
 
extern "C" {
    void test_list_files();
}
 
std::string userDataPath = "/user_data";
std::string userCloudPath = "/user_cloud";
 
void list_subfolder(const std::string& folder, const std::string& short_folder, const std::string& prefix = "")
{
    std::cout << prefix << short_folder << "/\n";
 
    DIR *d = opendir(folder.c_str());
    if (d)
    {
        struct dirent *entry = NULL;
        while((entry = readdir(d)))
        {
            if (entry->d_name[0] == '.') continue;
            if ((entry->d_type & DT_DIR)>0) {
                list_subfolder(folder + '/' + entry->d_name, entry->d_name, prefix + "  ");
            } else {
                std::cout << prefix << "  " << entry->d_name << "\n";
            }
        }
        closedir(d);
    }
}
 
void list_folder(const std::string& folder)
{
    std::cout << "Listing files\n";
    list_subfolder(folder, folder);
}
 
void test_list_files()
{
    list_folder(userDataPath);
    list_folder(userCloudPath);
}
 
int main(int argc, char * argv[])
{
    std::cout << "Welcome Main\n";
    // call dummy function to init cloud
    humble_init();
 
    return 0;
}