Source:
Code: Select all
#include <pspdisplay.h>
#include <pspctrl.h> 
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspaudio.h>
#include <pspaudiolib.h>
#include <pspiofilemgr.h>
#include <pspiofilemgr_stat.h>
#include <pspiofilemgr_dirent.h>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include "songlist.cpp"
PSP_MODULE_INFO("Files", 0, 1, 1); 
using namespace std;
vector<string> slist;
//#define printf pspDebugScreenPrintf 
//There be dragons here:
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
          sceKernelExitGame();
          return 0;
}
/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
          int cbid;
          cbid = sceKernelCreateCallback("Exit Callback", exit_callback, 
NULL);
          sceKernelRegisterExitCallback(cbid);
          sceKernelSleepThreadCB();
          return 0;
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
          int thid = 0;
          thid = sceKernelCreateThread("update_thread", CallbackThread, 
0x11, 0xFA0, 0, 0);
          if(thid >= 0) {
                    sceKernelStartThread(thid, 0, 0);
          }
          return thid;
} 
void getList(char *path){
	char newPath[80];
	SceUID fd = sceIoDopen(path);
	if (fd >= 0) {
		char *curdir;
   		for (;;) {
      			struct SceIoDirent entry;
      			memset(&entry, 0, sizeof(struct SceIoDirent));
      			if (sceIoDread(fd, &entry) <= 0)
         			break;
			if ((entry.d_stat.st_mode&FIO_S_IFDIR)==FIO_S_IFDIR) {
				if(!strcmp(entry.d_name,".") || !strcmp(entry.d_name,"..")){
					
				} else {
					//printf("%s [DIR]\n", entry.d_name);
					sprintf(newPath, "%s%s", path,entry.d_name);
					//printf("  ==>  %s\n",newPath);
					getList(newPath);
					
					sprintf(curdir,"%s",newPath);
				}				
			} else {	
				string tmp(entry.d_name);
				//sprintf(tmp,"%s", entry.d_name);
				slist.push_back(tmp);
				//printf("%s [FILE]\n", entry.d_name);
				//a->insertBack(0,*entry.d_name);
				
			}
   		}
	}
	sceIoDclose(fd);
}
int main () {
	pspDebugScreenInit();
	SetupCallbacks();
	char file[40] = "ms0:/MUSIC/";
	getList(file);
	/*song tmp;
	for(int i = 0; i < list.size(); i++){
		tmp = list.at(i);
		printf("%s\n",tmp.path);
	}*/
	sceKernelSleepThread();
	return 0;
}
Code: Select all
make -k 
psp-g++ -I.. -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -I.. -I. -I/usr/local/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=390    -c -o main.o main.cpp
main.cpp: In function ‘void getList(char*)’:
main.cpp:81: error: variable ‘std::string tmp’ has initializer but incomplete type
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_vector.h: In destructor ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _Alloc = std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]’:
mksfo 'File Manipulation' PARAM.SFO
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_vector.h:203:   instantiated from ‘std::vector<_Tp, _Alloc>::vector(const _Alloc&) [with _Tp = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _Alloc = std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]’
main.cpp:22:   instantiated from here
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_vector.h:119: error: invalid use of undefined type ‘struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >’
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stringfwd.h:56: error: declaration of ‘struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >’
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_construct.h: In function ‘void std::__destroy_aux(_ForwardIterator, _ForwardIterator, __false_type) [with _ForwardIterator = std::basic_string<char, std::char_traits<char>, std::allocator<char> >*]’:
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_construct.h:155:   instantiated from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = std::basic_string<char, std::char_traits<char>, std::allocator<char> >*]’
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_construct.h:182:   instantiated from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator, std::allocator<_T2>) [with _ForwardIterator = std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, _Tp = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]’
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_vector.h:272:   instantiated from ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _Alloc = std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]’
main.cpp:22:   instantiated from here
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_construct.h:121: error: cannot increment a pointer to incomplete type ‘std::basic_string<char, std::char_traits<char>, std::allocator<char> >’
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_construct.h: In function ‘void std::_Destroy(_Tp*) [with _Tp = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]’:
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_construct.h:122:   instantiated from ‘void std::__destroy_aux(_ForwardIterator, _ForwardIterator, __false_type) [with _ForwardIterator = std::basic_string<char, std::char_traits<char>, std::allocator<char> >*]’
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_construct.h:155:   instantiated from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = std::basic_string<char, std::char_traits<char>, std::allocator<char> >*]’
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_construct.h:182:   instantiated from ‘void std::_Destroy(_ForwardIterator, _ForwardIterator, std::allocator<_T2>) [with _ForwardIterator = std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, _Tp = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]’
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_vector.h:272:   instantiated from ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, _Alloc = std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]’
main.cpp:22:   instantiated from here
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stl_construct.h:107: error: invalid use of undefined type ‘struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >’
/usr/local/pspdev/lib/gcc/psp/4.1.0/../../../../include/c++/4.1.0/bits/stringfwd.h:56: error: declaration of ‘struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >’
make: *** [main.o] Error 1
make: Target `all' not remade because of errors.