Statistics: Posted by Mysoft — Tue Dec 14, 2021 12:32 am
Statistics: Posted by HudsonBr — Fri Jun 04, 2021 3:50 pm
Statistics: Posted by elhobbs — Fri Dec 06, 2013 1:54 pm
Statistics: Posted by Reylak — Fri Sep 06, 2013 4:50 pm
Code:
#include <stdio.h>#include <dirent.h>#include <sys/stat.h>#include <string.h>#include <unistd.h>int myReaddir(const char *Path) { static char path[PATH_MAX]; struct dirent *dent; struct stat st; DIR *dp; char *p, *end = path + PATH_MAX - 1; size_t len = strlen(Path); if(Path[0] != '/') { /* a relative directory */ if(getcwd(path, sizeof(path)) == NULL) { return 1; } } else if(len < PATH_MAX-1) { /* an absolute directory */ strcpy(path, Path); } else { return 1; } /* this is where we append each entry's name to the path */ p = path + len; /* make sure there's a trailing slash */ if(p[-1] != '/') { if(p < end-1) { *p++ = '/'; *p = 0; } } /* open the directory */ dp = opendir(Path); if(dp == NULL) { return 1; } /* loop through each directory entry */ while((dent = readdir(dp)) != NULL) { /* let's make sure the path + name fit */ if(p + strlen(dent->d_name) < end) { /* append the name to the path */ strcpy(p, dent->d_name); /* stat the path */ if(stat(path, &st) != 0) { /* an error, do what you want */ } else { /* everything successful for this entry */ printf("%s\n", dent->d_name); printf(" Directory: %s\n", dent->d_type == DT_DIR ? "true" : "false"); printf(" Size: %zu\n", st.st_size); } } else { /* this name was too long, do what you want */ } } closedir(dp); return 0;}int main(int argc, char *argv[]) { const char *path = argv[1]; if(path != NULL) return myReaddir(path); else return 1;}
Statistics: Posted by mtheall — Fri Sep 06, 2013 3:48 pm
Statistics: Posted by WinterMute — Thu Sep 05, 2013 11:11 pm
Code:
struct dirent *elem; struct stat st; const char *dirName = luaL_checkstring(L, 1); // luaL_checkstring() just gives the name of the folder to be listed DIR *dir = opendir(dirName); while ((elem = readdir(dir))) { lua_pushstring(L, elem->d_name); lua_pushboolean(L, elem->d_type == DT_DIR); stat(elem->d_name, &st); lua_pushnumber(L, st.st_size); }
Statistics: Posted by Reylak — Thu Aug 22, 2013 3:40 pm
Code:
#include <nds.h>#include <fat.h>#include <string.h>#include <dirent.h>#include <stdio.h>#include <stdlib.h>#include <dswifi9.h>#include <maxmod9.h>#include "soundbank.h"#include "soundbank_bin.h"//objectsint bcartex64_texid;int cratetex64_texid;int cratemetaltex64_texid;int cratet3tex64_texid;//solovoid map0(void) //test [model viewer]{//cameraint rx = 0, ry = 0;int oldx = 0, oldy = 0;int p1xpos = -20, p1ypos = -0;//modelsint modelnum = 0;touchPosition touchXY;videoSetMode(MODE_0_3D);//initialize the geometry engineglInit();//enable antialiasingglEnable(GL_ANTIALIAS);glClearColor(0,128,128,31); glClearPolyID(63); glClearDepth(0x7FFF);// Set our viewport to be the same size as the screenglViewport(0,0,255,191);{//texturesvramSetBankA(VRAM_A_TEXTURE);glEnable(GL_TEXTURE_2D);//crate textureglGenTextures( 1, &cratetex64_texid ); glBindTexture( 0, cratetex64_texid );glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_64, TEXTURE_SIZE_64, 0, TEXGEN_TEXCOORD, "cratetex64.bin");//crate metal textureglGenTextures( 1, &cratemetaltex64_texid ); glBindTexture( 0, cratemetaltex64_texid );glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_64, TEXTURE_SIZE_64, 0, TEXGEN_TEXCOORD, "cratemetaltex64.bin");//crate t3 textureglGenTextures( 1, &cratet3tex64_texid ); glBindTexture( 0, cratet3tex64_texid );glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_64, TEXTURE_SIZE_64, 0, TEXGEN_TEXCOORD, "cratet3tex64.bin");//crate t3 textureglGenTextures( 1, &bcartex64_texid ); glBindTexture( 0, bcartex64_texid );glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_64, TEXTURE_SIZE_64, 0, TEXGEN_TEXCOORD, "bcartex64.bin");}{//bottom screen stuffvideoSetModeSub(MODE_0_2D);PrintConsole bottomScreen;vramSetBankC(VRAM_C_SUB_BG);consoleInit(&bottomScreen, 0,BgType_Text4bpp, BgSize_T_256x256, 31, 0, false, true);iprintf("T3-Games-Zero [Model view]");printf("\x1b[3;1HPress D-Pad> Movement.");printf("\x1b[4;1HTouch> Rotate");//main loopwhile (1) {scanKeys(); touchRead(&touchXY);int held = keysHeld(), pressed = keysDown();{//insert to move camera around hereif(held & KEY_RIGHT && p1ypos > -10)p1ypos -=1;if(held & KEY_LEFT && p1ypos < 10)p1ypos +=1;if(held & KEY_DOWN && p1xpos > -35)p1xpos -=1;if(held & KEY_UP && p1xpos <-5)p1xpos +=1;}printf("\x1b[5;2HPress L/R> Change Model %d - 1", modelnum);{//model changeif(pressed & KEY_L && modelnum > 0) modelnum -=1;if(pressed & KEY_R && modelnum < 2)modelnum +=1;}//reset x and y when user touches screenif(pressed & KEY_TOUCH){oldx = touchXY.px; oldy = touchXY.py;}//if user drags then grab the deltaif(held & KEY_TOUCH){rx += touchXY.px - oldx; oldx = touchXY.px;ry += touchXY.py - oldy; oldy = touchXY.py;}//handle cameraglMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(70, 256.0 / 192.0, 0.1, 175);glPolyFmt(POLY_ALPHA(31)| POLY_CULL_NONE );glMaterialShinyness ();{//lightingglLight(0, RGB15(31,31,31), 0, floattov10(-1.0) , 0);glLight(1, RGB15(31,0,31) , 0,floattov10(1) - 1, 0);glLight(2, RGB15(0,31,0) , floattov10(-1.0), 0, 0);glLight(3, RGB15(0,0,31) , floattov10(1.0) - 1,0,0);}glMatrixMode(GL_MODELVIEW);glLoadIdentity();glTranslatef(0,0,-10); glTranslatef(p1ypos,0,p1xpos); glRotateY(rx);glRotateX(ry);printf("\x1b[9;5HtestRX:%d ", rx);printf("\x1b[10;6HtestRY:%d ", ry);printf("\x1b[11;7HtestPX:%d ", touchXY.px);printf("\x1b[12;8HtestPY:%d ", touchXY.px);if(modelnum == 0){//nothingprintf("\x1b[6;2HNothing");}//nothingif(modelnum == 1){//crates//crateprintf("\x1b[6;2HCrates ");glPushMatrix();glMatrixMode(GL_TEXTURE);glLoadIdentity();glMatrixMode(GL_MODELVIEW);glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_FORMAT_LIGHT1 | POLY_FORMAT_LIGHT2 | POLY_FORMAT_LIGHT3 ) ;glMaterialf(GL_AMBIENT, RGB15(8,8,8)); glMaterialf(GL_DIFFUSE, RGB15(16,16,16));glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8)); glMaterialf(GL_EMISSION, RGB15(5,5,5));glTranslatef(0,0,0); glScalef32(10000,10000,10000);glBindTexture( 0, cratetex64_texid );glCallList((u32*)"crate64.bin");glPopMatrix(1);//cratemetalglPushMatrix();glMatrixMode(GL_TEXTURE);glLoadIdentity();glMatrixMode(GL_MODELVIEW);glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_FORMAT_LIGHT1 | POLY_FORMAT_LIGHT2 | POLY_FORMAT_LIGHT3 ) ;glMaterialf(GL_AMBIENT, RGB15(8,8,8));glMaterialf(GL_DIFFUSE, RGB15(16,16,16));glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8));glMaterialf(GL_EMISSION, RGB15(5,5,5));glTranslatef(10,0,-10); //glRotateX(ry); glRotateY(rx);glScalef32(10000,10000,10000);glBindTexture( 0, cratemetaltex64_texid );glCallList((u32*)"crate64.bin");glPopMatrix(1);//cratet3glPushMatrix();glMatrixMode(GL_TEXTURE);glLoadIdentity();glMatrixMode(GL_MODELVIEW);glPolyFmt(POLY_ALPHA(31) | POLY_CULL_BACK | POLY_FORMAT_LIGHT0 | POLY_FORMAT_LIGHT1 | POLY_FORMAT_LIGHT2 | POLY_FORMAT_LIGHT3 ) ;glMaterialf(GL_AMBIENT, RGB15(8,8,8));glMaterialf(GL_DIFFUSE, RGB15(16,16,16));glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8));glMaterialf(GL_EMISSION, RGB15(5,5,5));glTranslatef(-10,0,-10); //glRotateX(ry); glRotateY(rx);glScalef32(10000,10000,10000);glBindTexture( 0, cratet3tex64_texid );glCallList((u32*)"crate64.bin");glPopMatrix(1);}//cratesif(modelnum == 2){//carprintf("\x1b[6;2HCar ");glPushMatrix();glMatrixMode(GL_TEXTURE);glLoadIdentity();glMatrixMode(GL_MODELVIEW);glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE | POLY_FORMAT_LIGHT0 | POLY_FORMAT_LIGHT1 | POLY_FORMAT_LIGHT2 | POLY_FORMAT_LIGHT3 ) ;glMaterialf(GL_AMBIENT, RGB15(8,8,8));glMaterialf(GL_DIFFUSE, RGB15(16,16,16));glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8,8,8));glMaterialf(GL_EMISSION, RGB15(5,5,5));glTranslatef(0,0,0); glScalef32(10000,10000,10000);glBindTexture( 0, bcartex64_texid );glCallList((u32*)"bcar64.bin");glPopMatrix(1);}//carswiWaitForVBlank();// flush to the screenglFlush(0);}}
Statistics: Posted by t377y000 — Sat May 19, 2012 2:59 am