forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED]Percentage when copy a file...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Fri Mar 14, 2008 1:50 am    Post subject: [SOLVED]Percentage when copy a file... Reply with quote

I will show the percentage when a file is copying in this function:

int fileCopy(char* inSrc , char* inDest) {
SceUID tempSrc = sceIoOpen(inSrc, PSP_O_RDONLY, 0777);
if(!tempSrc){
printf("Error...\n");
}
SceUID tempDest = sceIoOpen(inDest, PSP_O_WRONLY | PSP_O_CREAT, 0777);
if(!tempDest) {
sceIoClose(tempSrc);
printf("Error...\n");
}

char tempData[1024];
int tempRead = sceIoRead(tempSrc, tempData, 1024);
int tempWritten;

while(tempRead > 0) {
tempWritten = sceIoWrite(tempDest, tempData, tempRead);
if(tempWritten != tempRead) {
sceIoClose(tempDest);
sceIoClose(tempSrc);
sceIoRemove(inDest);
printf("Error...\n");
}
tempRead = sceIoRead(tempSrc, tempData, 1024);

}

sceIoClose(tempDest);
sceIoClose(tempSrc);
return 1;
}

Have someone a solution?
Or how to get the file lenght?
I'll make a comparison between the read file and the file in writing to get
the current progress, it's possible?


Last edited by ne0h on Mon Mar 17, 2008 3:18 am; edited 1 time in total
Back to top
View user's profile Send private message
sakya



Joined: 28 Apr 2006
Posts: 190

PostPosted: Fri Mar 14, 2008 2:56 am    Post subject: Re: Percentage when copy a file... Reply with quote

Hi! :)
ne0h wrote:
Or how to get the file lenght?


You can use stat:
Code:
#include <sys/stat.h>
struct stat stbuf;
if(stat(fileName, &stbuf) == -1)
   return -1;
fileSize = stbuf.st_size;


or move to 0 bytes from the end of the file:
Code:
fd = sceIoOpen(filename, PSP_O_RDONLY, 0777);
if (fd < 0)
   return -1;
fileSize = sceIoLseek32(fd, 0, PSP_SEEK_END);
sceIoLseek32(fd, 0, PSP_SEEK_SET);


Ciaooo
Sakya
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group