Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sdk:scripts:mount-media [2015/05/05 15:04] (current)
Line 1: Line 1:
 +====== SDK Script mount-media.are ======
 +<code c mount-media.are>​
 +/* DESC: This script can be used to mount an USB storage stick.
 + * Copyright (C) 2012 NetModule AG, Switzerland
 + */
 +
 +device = "​usb0";​
 +mntpoint = "/​mnt/​media/​usb0";​
 +
 +ret = nb_media_mount(device);​
 +if (ret == 0) {
 +    printf("​Successfully mounted usb0\n"​);​
 +}
 +else {
 +  printf("​Unable to mount usb0 (rc %d)\n",​ ret);
 +}
 +
 +printf("​\nMounted media:​\n"​);​
 +mounted = nb_media_getmount();​
 +printf("​%s\n",​ mounted);
 +
 +
 +printf("​Files at %s:​\n\n",​ mntpoint);
 +
 +handle = opendir(mntpoint);​
 +if (handle != -1) {
 +    while ((entry = readdir(handle))) {
 +        if (left(entry,​ 1) == "​."​) continue;
 +        printf("​%s\n",​ entry);
 +    }
 +    closedir(handle);​
 +} else {
 +    printf("​cannot open directory %s", mntpoint);
 +}
 +
 +nb_media_umount(device);​
 +
 +exit(0);
 +
 +</​code>​