Changeset 654
- Timestamp:
- 12/28/08 09:23:42 (4 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 8 edited
-
core/edgeoverlay.c (modified) (1 diff)
-
core/gui_fselect.c (modified) (7 diffs)
-
include/stdlib.h (modified) (1 diff)
-
lib/lua/lbaselib.c (modified) (2 diffs)
-
lib/lua/liolib.c (modified) (1 diff)
-
lib/lua/loadlib.c (modified) (1 diff)
-
lib/lua/loslib.c (modified) (6 diffs)
-
makefile.inc (modified) (1 diff)
-
tools/hostlua (added)
-
tools/hostlua/Makefile (added)
-
tools/hostlua/include (added)
-
tools/hostlua/include/lauxlib.h (added)
-
tools/hostlua/include/lua.h (added)
-
tools/hostlua/include/luaconf.h (added)
-
tools/hostlua/include/lualib.h (added)
-
tools/hostlua/include/readme.txt (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/edgeoverlay.c
r599 r654 122 122 while( (de = readdir(d)) ) 123 123 { 124 fr = get_edge_file_num(de-> name);124 fr = get_edge_file_num(de->d_name); 125 125 if( fr > fnum ) 126 126 { -
trunk/core/gui_fselect.c
r651 r654 124 124 de = readdir(d); 125 125 while (de) { 126 if (de-> name[0] != 0xE5 /* deleted entry */ && (de->name[0]!='.' || de->name[1]!=0)) {126 if (de->d_name[0] != 0xE5 /* deleted entry */ && (de->d_name[0]!='.' || de->d_name[1]!=0)) { 127 127 *ptr = malloc(sizeof(struct fitem)); 128 128 if (*ptr) { 129 129 (*ptr)->n = count; 130 (*ptr)->name = malloc(strlen(de-> name)+1);130 (*ptr)->name = malloc(strlen(de->d_name)+1); 131 131 if ((*ptr)->name) 132 strcpy((*ptr)->name, de-> name);133 sprintf(buf, "%s/%s", dir, de-> name);132 strcpy((*ptr)->name, de->d_name); 133 sprintf(buf, "%s/%s", dir, de->d_name); 134 134 if (stat(buf, &st)==0) { 135 135 (*ptr)->attr=st.st_attrib; … … 137 137 (*ptr)->mtime=st.st_mtime; 138 138 } else { 139 (*ptr)->attr=(de-> name[0]=='.' && de->name[1]=='.' && de->name[2]==0)?DOS_ATTR_DIRECTORY:0xFF;139 (*ptr)->attr=(de->d_name[0]=='.' && de->d_name[1]=='.' && de->d_name[2]==0)?DOS_ATTR_DIRECTORY:0xFF; 140 140 (*ptr)->size=(*ptr)->mtime=0; 141 141 } … … 401 401 d=opendir(current_dir); 402 402 while ((de=readdir(d)) != NULL) {//Loop to find all Canon folders 403 if (de-> name[0] != '.' && de->name[1] != '.') {//If item is not UpDir404 sprintf(sub_dir, "%s/%s", current_dir, de-> name);403 if (de->d_name[0] != '.' && de->d_name[1] != '.') {//If item is not UpDir 404 sprintf(sub_dir, "%s/%s", current_dir, de->d_name); 405 405 d2=opendir(sub_dir); 406 406 while ((de2=readdir(d2)) != NULL) {//Loop to find all the RAW files inside a Canon folder 407 if (de2-> name[0] == 'C' || de2->name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension)407 if (de2->d_name[0] == 'C' || de2->d_name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension) 408 408 d3=opendir(current_dir); 409 409 while ((de3=readdir(d3)) != NULL) {//Loop to find all Canon folders 410 if (de3-> name[0] != '.' && de3->name[1] != '.') {//If item is not UpDir411 sprintf(sub_dir_search, "%s/%s", current_dir, de3-> name);410 if (de3->d_name[0] != '.' && de3->d_name[1] != '.') {//If item is not UpDir 411 sprintf(sub_dir_search, "%s/%s", current_dir, de3->d_name); 412 412 d4=opendir(sub_dir_search); 413 413 while ((de4=readdir(d4)) != NULL) {//Loop to find a corresponding JPG file inside a Canon folder 414 if (de2-> name[4] == de4->name[4] && de2->name[5] == de4->name[5] &&//If the four digits of the Canon number are the same415 de2-> name[6] == de4->name[6] && de2->name[7] == de4->name[7] &&416 de4-> name[9] == 'J' && !(de4->name[0] == 'C' || de4->name[9] == 'C' || de4->name[0] == 0xE5)) {//If file is JPG, is not CRW/CR2 and is not a deleted item414 if (de2->d_name[4] == de4->d_name[4] && de2->d_name[5] == de4->d_name[5] &&//If the four digits of the Canon number are the same 415 de2->d_name[6] == de4->d_name[6] && de2->d_name[7] == de4->d_name[7] && 416 de4->d_name[9] == 'J' && !(de4->d_name[0] == 'C' || de4->d_name[9] == 'C' || de4->d_name[0] == 0xE5)) {//If file is JPG, is not CRW/CR2 and is not a deleted item 417 417 started(); 418 418 found=1;//A JPG file with the same Canon number was found … … 425 425 //If no JPG found, delete RAW file 426 426 if (found == 0) { 427 sprintf(selected_item, "%s/%s", sub_dir, de2-> name);427 sprintf(selected_item, "%s/%s", sub_dir, de2->d_name); 428 428 remove(selected_item); 429 429 finished(); … … 448 448 d=opendir(current_dir); 449 449 while ((de=readdir(d)) != NULL) {//Loop to find all the RAW files inside the Canon folder 450 if (de-> name[0] == 'C' || de->name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension)450 if (de->d_name[0] == 'C' || de->d_name[9] == 'C') {//If file is RAW (Either CRW/CR2 prefix or file extension) 451 451 d2=opendir(current_dir); 452 452 while ((de2=readdir(d2)) != NULL) {//Loop to find a corresponding JPG file inside the Canon folder 453 if (de-> name[4] == de2->name[4] && de->name[5] == de2->name[5] &&//If the four digits of the Canon number are the same454 de-> name[6] == de2->name[6] && de->name[7] == de2->name[7] &&455 de2-> name[9] == 'J' && !(de2->name[0] == 'C' || de2->name[9] == 'C' || de2->name[0] == 0xE5)) {//If file is JPG and is not CRW/CR2 and is not a deleted item453 if (de->d_name[4] == de2->d_name[4] && de->d_name[5] == de2->d_name[5] &&//If the four digits of the Canon number are the same 454 de->d_name[6] == de2->d_name[6] && de->d_name[7] == de2->d_name[7] && 455 de2->d_name[9] == 'J' && !(de2->d_name[0] == 'C' || de2->d_name[9] == 'C' || de2->d_name[0] == 0xE5)) {//If file is JPG and is not CRW/CR2 and is not a deleted item 456 456 started(); 457 457 found=1;//A JPG file with the same Canon number was found … … 461 461 //If no JPG found, delete RAW file 462 462 if (found == 0) { 463 sprintf(selected_item, "%s/%s", current_dir, de-> name);463 sprintf(selected_item, "%s/%s", current_dir, de->d_name); 464 464 remove(selected_item); 465 465 finished(); … … 519 519 de = readdir(d); 520 520 while (de) { 521 if (de-> name[0] != 0xE5 /* deleted entry */ && (de->name[0]!='.' || (de->name[1]!='.' && de->name[1]!=0) || (de->name[1]=='.' && de->name[2]!=0))) {521 if (de->d_name[0] != 0xE5 /* deleted entry */ && (de->d_name[0]!='.' || (de->d_name[1]!='.' && de->d_name[1]!=0) || (de->d_name[1]=='.' && de->d_name[2]!=0))) { 522 522 started(); 523 sprintf(selected_file, "%s/%s", current_dir, de-> name);523 sprintf(selected_file, "%s/%s", current_dir, de->d_name); 524 524 remove(selected_file); 525 525 finished(); -
trunk/include/stdlib.h
r606 r654 213 213 #if !CAM_DRYOS 214 214 struct dirent { 215 char name[100];215 char d_name[100]; 216 216 }; 217 217 #else 218 218 struct dirent { 219 char name[13];219 char d_name[13]; 220 220 unsigned long unk1; 221 221 unsigned char attrib; -
trunk/lib/lua/lbaselib.c
r525 r654 11 11 #include <stdlib.h> 12 12 #include <string.h> 13 #ifndef HOST_LUA 13 14 #include <script.h> // script_console_add_line 15 #endif 14 16 15 17 #define lbaselib_c … … 71 73 72 74 } 75 #ifdef HOST_LUA 76 fprintf(stdout,"%s\n",buf); 77 #else 73 78 script_console_add_line(buf); 79 #endif 74 80 75 81 return 0; -
trunk/lib/lua/liolib.c
r517 r654 22 22 #include "lualib.h" 23 23 24 24 #ifdef HOST_LUA 25 #include <errno.h> 26 #include <ctype.h> 27 #endif 25 28 26 29 #define IO_INPUT 1 -
trunk/lib/lua/loadlib.c
r515 r654 331 331 332 332 static int readable (const char *filename) { 333 #ifdef HOST_LUA 334 FILE *f = fopen(filename, "r"); /* try to open file */ 335 if (f == NULL) return 0; /* open failed */ 336 fclose(f); 337 #else 333 338 int f = open(filename,O_RDONLY,0777); 334 339 if (f == -1) return 0; /* open failed */ 335 340 close(f); 341 #endif 336 342 return 1; 337 343 } -
trunk/lib/lua/loslib.c
r555 r654 11 11 #include <stdlib.h> 12 12 #include <string.h> 13 #if 0 13 #ifdef HOST_LUA 14 #include <errno.h> 14 15 #include <time.h> 16 #include <dirent.h> 17 #include <sys/stat.h> 18 #include <utime.h> 15 19 #endif 16 20 … … 246 250 static int os_mkdir (lua_State *L) { 247 251 const char *dirname = luaL_checkstring(L, 1); 252 #if defined(HOST_LUA) && !defined(_WIN32) 253 return os_pushresult(L, mkdir(dirname,0777) == 0, dirname); 254 #else 248 255 return os_pushresult(L, mkdir(dirname) == 0, dirname); 256 #endif 249 257 } 250 258 … … 267 275 lua_newtable(L); 268 276 while((de = readdir(dir))) { 269 if(!all && ( de->name[0] == 0xE5 || (strcmp(de->name,".")==0) || (strcmp(de->name,"..")==0)))277 if(!all && (/*de->d_name[0] == 0xE5 ||*/ (strcmp(de->d_name,".")==0) || (strcmp(de->d_name,"..")==0))) 270 278 continue; 271 279 lua_pushinteger(L, i); 272 lua_pushstring(L, de-> name);280 lua_pushstring(L, de->d_name); 273 281 lua_settable(L,-3); 274 282 ++i; … … 302 310 setfield(L,"mtime",st.st_mtime); /* time of last modification */ 303 311 setfield(L,"ctime",st.st_ctime); /* time of last change of file status */ 312 #ifdef HOST_LUA 313 // fill in some sane values if we aren't running on the camera 314 // from chdk stdlib 315 #define DOS_ATTR_DIRECTORY 0x10 /* entry is a sub-directory */ 316 setfield(L,"blksize",512); 317 setfield(L,"blocks",(st.st_size/512) + (st.st_size%512)?1:0); 318 if ( S_ISDIR(st.st_mode) ) { 319 setfield(L,"attrib",DOS_ATTR_DIRECTORY); 320 setboolfield(L,"is_dir",1); 321 setboolfield(L,"is_file",0); 322 } 323 else { 324 setboolfield(L,"is_dir",0); 325 setfield(L,"attrib",0); 326 if S_ISREG(st.st_mode) { 327 setboolfield(L,"is_file",1); 328 } 329 } 330 #else 304 331 setfield(L,"blksize",st.st_blksize); /* This is NOT the dos sector size. Appears to be 512 on all I've tested! */ 305 332 setfield(L,"blocks",st.st_blocks); /* number of blocks required to store file. May not be the same as size on disk, per above*/ … … 309 336 setboolfield(L,"is_dir",st.st_attrib & DOS_ATTR_DIRECTORY); 310 337 setboolfield(L,"is_file",!(st.st_attrib & (DOS_ATTR_DIRECTORY | DOS_ATTR_VOL_LABEL))); 338 #endif 311 339 #if 0 312 340 setfield(L,"reserved1",st.reserved1); … … 354 382 {"stat", os_stat}, // reyalp - NOT STANDARD 355 383 {"utime", os_utime}, // reyalp - NOT STANDARD 356 // TODO add directory listing functions357 384 {"remove", os_remove}, 358 385 {"rename", os_rename}, -
trunk/makefile.inc
r638 r654 262 262 HOSTCC=gcc 263 263 HOSTCFLAGS=-g -O2 -Wall 264 HOSTAR=ar 264 265 265 266 PAKWIF=$(topdir)tools/pakwif$(EXE)
Note: See TracChangeset
for help on using the changeset viewer.