-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix example
- Loading branch information
Showing
5 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# _____ ___ ____ ___ ____ | ||
# ____| | ____| | | |____| | ||
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. | ||
#----------------------------------------------------------------------- | ||
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org | ||
# Licenced under Academic Free License version 2.0 | ||
# Review ps2sdk README & LICENSE files for further details. | ||
|
||
SAMPLE_DIR = libcglue/readdir | ||
|
||
include $(PS2SDKSRC)/Defs.make | ||
include $(PS2SDKSRC)/samples/Rules.samples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# _____ ___ ____ ___ ____ | ||
# ____| | ____| | | |____| | ||
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. | ||
#----------------------------------------------------------------------- | ||
# Copyright 2001-2004, ps2dev - http://www.ps2dev.org | ||
# Licenced under Academic Free License version 2.0 | ||
# Review ps2sdk README & LICENSE files for further details. | ||
|
||
SCREEN_DEBUG = 1 | ||
VERBOSE = 0 | ||
|
||
EE_BIN = rewinddir_test.elf | ||
EE_OBJS = main.o | ||
|
||
ifeq ($(SCREEN_DEBUG), 1) | ||
EE_LIBS += -ldebug | ||
EE_CFLAGS += -DSCREEN_DEBUG | ||
endif | ||
|
||
ifeq ($(VERBOSE), 1) | ||
EE_CFLAGS += -DVERBOSE | ||
endif | ||
|
||
all: $(EE_BIN) input | ||
|
||
input: | ||
mkdir -p testfiles/ | ||
echo "hello world" > testfiles/dummy | ||
|
||
clean: | ||
rm -rf $(EE_BIN) $(EE_OBJS) | ||
|
||
run: $(EE_BIN) | ||
ps2client execee host:$(EE_BIN) | ||
|
||
reset: | ||
ps2client reset | ||
|
||
include $(PS2SDK)/samples/Makefile.pref | ||
include $(PS2SDK)/samples/Makefile.eeglobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
# _____ ___ ____ ___ ____ | ||
# ____| | ____| | | |____| | ||
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. | ||
#----------------------------------------------------------------------- | ||
# Copyright 2001-2005, ps2dev - http://www.ps2dev.org | ||
# Licenced under Academic Free License version 2.0 | ||
# Review ps2sdk README & LICENSE files for further details. | ||
# | ||
# Malloc tester | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <dirent.h> | ||
#include <unistd.h> | ||
#include <kernel.h> | ||
|
||
#if defined(SCREEN_DEBUG) | ||
#include <debug.h> | ||
#endif | ||
|
||
#if defined(SCREEN_DEBUG) | ||
#define custom_printf(args...) \ | ||
printf(args); \ | ||
scr_printf(args); | ||
#else | ||
#define custom_printf(args...) printf(args); | ||
#endif | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
// Buffer to store the current working directory | ||
char cwd[1024]; | ||
|
||
#if defined(SCREEN_DEBUG) | ||
init_scr(); | ||
sleep(3); | ||
#endif | ||
custom_printf("\n\nStarting rewinddir TESTS...\n"); | ||
|
||
// Get the current working directory | ||
if (getcwd(cwd, sizeof(cwd)) == NULL) { | ||
custom_printf("Error getting current working directory"); | ||
return 1; | ||
} | ||
|
||
// Open the current directory | ||
DIR *directory = opendir(cwd); | ||
|
||
// Check if the directory can be opened | ||
if (directory == NULL) { | ||
custom_printf("Error opening directory"); | ||
return 1; | ||
} | ||
|
||
// Read directory entries | ||
struct dirent *entry; | ||
while ((entry = readdir(directory)) != NULL) { | ||
// Check if the entry is a directory using d_type | ||
custom_printf("%s -> %s\n", entry->d_name, entry->d_type == DT_DIR ? "Directory" : "File"); | ||
} | ||
|
||
custom_printf("\n\nExecuting rewinddir function...\n"); | ||
rewinddir(directory); | ||
|
||
while ((entry = readdir(directory)) != NULL) { | ||
// Check if the entry is a directory using d_type | ||
custom_printf("%s -> %s\n", entry->d_name, entry->d_type == DT_DIR ? "Directory" : "File"); | ||
} | ||
|
||
custom_printf("\n\nTest finished!\n"); | ||
|
||
// Close the directory | ||
closedir(directory); | ||
|
||
SleepThread(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters