spBase
読み取り中…
検索中…
一致する文字列を見つけられません
dirtest.c
#include <stdio.h>
#include <stdlib.h>
#include <sp/spBaseLib.h>
#include <sp/spMain.h>
static spBool printDir(char *dirname)
{
DIR *dirp;
struct dirent *direntp;
if ((dirp = spOpenDir(dirname)) == NULL) {
fprintf(stderr, "Can't open directory: %s\n", dirname);
return SP_FALSE;
}
printf("reading directory: %s\n", dirname);
while ((direntp = spReadDir(dirp)) != NULL) {
printf("%s\n", direntp->d_name);
}
spCloseDir(dirp);
return SP_TRUE;
}
int spMain(int argc, char *argv[])
{
#if defined(MACOS9)
static char dirname[] = ":";
#else
static char dirname[] = ".";
#endif
char *name;
printf("process id = %ld\n", spGetProcessId());
printDir(dirname);
if ((name = xspGetHomeDir()) != NULL) {
printf("home directory: %s\n", name);
printDir(name);
xspFree(name);
}
if ((name = xspGetCurrentDir()) != NULL) {
printf("current directory: %s\n", name);
xspFree(name);
}
if ((name = xspGetTempDir()) != NULL) {
printf("temporary directory: %s\n", name);
xspFree(name);
}
if ((name = xspGetExactName("~/hoge")) != NULL) {
printf("~/hoge --> %s\n", name);
xspFree(name);
}
if ((name = xspGetExactName("~ftp/hoge")) != NULL) {
printf("~ftp/hoge --> %s\n", name);
xspFree(name);
}
/* functions introduced from version 0.8.9 */
{
spBool id_depend = SP_FALSE;
spBool version_depend = SP_FALSE;
const char *name2;
#if 0
name2 = spGetApplicationDir(&version_depend);
printf("application directory (before set application ID): %s (version depend: %d)\n",
name2, version_depend);
#endif
#if 1
#elif 0
version_depend = SP_TRUE;
spSetApplicationId("test/0.1");
#endif
if (1) {
id_depend = SP_TRUE;
name2 = spCreateApplicationDir(&id_depend, &version_depend);
printf("create application directory: %s (id depend: %d, version depend: %d)\n",
name2, id_depend, version_depend);
}
name2 = spGetApplicationDir(&version_depend);
printf("application directory: %s (version depend: %d)\n", name2, version_depend);
if (version_depend == SP_TRUE) {
version_depend = SP_FALSE;
name2 = spGetApplicationDir(&version_depend);
printf("application directory: %s (version depend: %d)\n", name2, version_depend);
version_depend = SP_TRUE;
}
printf("application temp directory: %s\n", name2);
if ((name = xspGetDocumentDir(SP_FILE_KIND_DOCUMENT)) != NULL) {
printf("document directory: %s\n", name);
xspFree(name);
}
if ((name = xspGetDocumentDir(SP_FILE_KIND_PICTURE)) != NULL) {
printf("picture directory: %s\n", name);
xspFree(name);
}
if ((name = xspGetDocumentDir(SP_FILE_KIND_SOUND)) != NULL) {
printf("sound directory: %s\n", name);
xspFree(name);
}
if ((name = xspGetDocumentDir(SP_FILE_KIND_MUSIC)) != NULL) {
printf("music directory: %s\n", name);
printDir(name);
xspFree(name);
}
if ((name = xspGetDocumentDir(SP_FILE_KIND_MOVIE)) != NULL) {
printf("movie directory: %s\n", name);
xspFree(name);
}
if ((name = xspGetDocumentDir(SP_FILE_KIND_ARCHIVE)) != NULL) {
printf("archive directory: %s\n", name);
xspFree(name);
}
printf("spExecBrowser for '../README.txt': status = %d\n",
spExecBrowser("..", "README.txt", SP_TRUE));
printf("spExecBrowser for 'http://www.google.com/intl/en/about/index.html': status = %d\n",
spExecBrowser("http://www.google.com/", "intl/en/about/index.html", SP_FALSE));
}
return 0;
}
char * xspGetTempDir(void)
const char * spCreateApplicationDir(spBool *id_depend, spBool *version_depend)
void spSetDebugLevel(int level)
const char * spGetApplicationTempDir(void)
spBool spSetApplicationId(const char *id)
char * xspGetCurrentDir(void)
long spGetProcessId(void)
spBool spExecBrowser(const char *base_url, const char *sub_url, spBool local_path)
const char * spGetApplicationDir(spBool *version_depend)
char * xspGetDocumentDir(spFileKind file_kind)
char * xspGetHomeDir(void)
char * xspGetExactName(const char *name)
@ SP_FILE_KIND_MOVIE
Definition spBase.h:33
@ SP_FILE_KIND_SOUND
Definition spBase.h:32
@ SP_FILE_KIND_DOCUMENT
Definition spBase.h:25
@ SP_FILE_KIND_PICTURE
Definition spBase.h:29
@ SP_FILE_KIND_MUSIC
Definition spBase.h:31
@ SP_FILE_KIND_ARCHIVE
Definition spBase.h:36
int spBool
Definition spDefs.h:248
#define SP_TRUE
Definition spDefs.h:250
#define SP_FALSE
Definition spDefs.h:251
DIR * spOpenDir(const char *path)
struct dirent * spReadDir(DIR *dirp)
int spCloseDir(DIR *dirp)
#define xspFree(p)
Definition spMemory.h:82