![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on Directory Checking Code within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I want code that checks for a dir. then apply a functions due to the availability of that dir. How ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
I want code that checks for a dir. then apply a functions due to the availability of that dir.
How about somethin like this: Code:
if dir {
(dirc name) then
(function)
}else{
(function)
}
Code:
if dir {
THX in advancs
__________________
Need a GFX Guy for EBOOT ICONS, BACkGROUNDS?? I can help you there. Just see some of my work. PM me for GFX. Last edited by pspfreak9; 11-25-2006 at 09:33 AM.. |
|
|
|
|
|
|
#2 |
![]() likes kittens....awww....
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
|
http://man.he.net/man3/getcwd
-= Double Post =- also, http://www.informit.com/guides/conte...eqNum=245&rl=1 -= Double Post =- GOOGLE is your one and only friend. Last edited by psphacker12.; 11-25-2006 at 09:26 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
#3 | ||
![]() ![]() Developer
|
Quote:
__________________
![]() Check out my homebrew & C tutorials at http://insomniac.0x89.org/ Coder formerly known as Insomniac197 Quote:
|
||
|
|
|
|
|
#4 |
|
read the code I put it does a better job of explaining than I do
![]() -= Double Post =- I changed it
__________________
Need a GFX Guy for EBOOT ICONS, BACkGROUNDS?? I can help you there. Just see some of my work. PM me for GFX. Last edited by pspfreak9; 11-25-2006 at 09:34 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
|
#5 |
![]() likes kittens....awww....
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
|
I found this
Code:
#include <errno.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
DIR *pdir;
struct dirent *pent;
pdir=opendir("."); //"." refers to the current dir
if (!pdir){
printf ("opendir() failure; terminating");
exit(1);
}
errno=0;
while ((pent=readdir(pdir))){
printf("%s", pent->d_name);
}
if (errno){
printf ("readdir() failure; terminating");
exit(1);
}
closedir(pdir);
}
|
|
|
|
|
|
#6 |
|
But how do I put that In the IF function
Cuase I dont want to open the dic If it finds the dirc then it does the function It is to make sure my app has all nessecry files when some one runs
__________________
Need a GFX Guy for EBOOT ICONS, BACkGROUNDS?? I can help you there. Just see some of my work. PM me for GFX. |
|
|
|
|
|
|
#7 | |
![]() ![]() Developer
|
Just use the functions to open directories/files and check the return values from them.
Use opendir for directories and fopen for files. Code:
pdir=opendir("thedir");
if(pdir == NULL)
printf ("Directory doesn't exist...");
Code:
FILE *fp = fopen("somefile.txt", "r");
if(fp == NULL)
printf("File doesn't exist...");
__________________
![]() Check out my homebrew & C tutorials at http://insomniac.0x89.org/ Coder formerly known as Insomniac197 Quote:
|
|
|
|
|
|
|
#9 |
|
But what if pdir is true (there) how do i make a IF function from that??
-= Double Post =- How would you put that in code -= Double Post =- Can someone help me please ![]() -= Double Post =- Come on
__________________
Need a GFX Guy for EBOOT ICONS, BACkGROUNDS?? I can help you there. Just see some of my work. PM me for GFX. Last edited by pspfreak9; 11-25-2006 at 11:36 AM.. Reason: Automerged Doublepost |
|
|
|
|
|
|
#11 |
|
no no no
your code is if it is == to NULL But what if it checks for the dirc then if it finds the dirc (the dirc is on the MS) then it does a function. what you are doing is when the dirc isnt there
__________________
Need a GFX Guy for EBOOT ICONS, BACkGROUNDS?? I can help you there. Just see some of my work. PM me for GFX. |
|
|
|
|
|
|
#12 |
![]() likes kittens....awww....
Join Date: Sep 2006
Real First Name: Erik
Location: Detroit
Just Played: Call of Duty:World at War
Posts: 628
Trader Feedback: 0
|
Code:
if(pdir != NULL)
{
function1();
}
== true != false Last edited by psphacker12.; 11-25-2006 at 12:19 PM.. Reason: Automerged Doublepost |
|
|
|
|
|
#13 | |
|
again that is false:
Quote:
NeverMind -= Double Post =- Thanks
__________________
Need a GFX Guy for EBOOT ICONS, BACkGROUNDS?? I can help you there. Just see some of my work. PM me for GFX. Last edited by pspfreak9; 11-25-2006 at 12:23 PM.. Reason: Automerged Doublepost |
||
|
|
|
|
|
#14 |
![]() ![]() Developer
|
psphacker12: That is incorrect:
== means "is equal to" != means "is not equal to" Taking the previous code: Code:
FILE *fp = fopen("somefile.txt", "r");
if(fp == NULL)
{
printf("File doesn't exist...");
}
else
{
// Put code here is the file does exist
}
|
|
|
|
![]() |
| Tags |
| checking , code , directory |
| Thread Tools | |
|
|