Closed LuanTeles closed 1 month ago
I think the issue is the while. Try this code:
if(cellFsOpen(src, CELL_FS_O_RDONLY, &fd_src, 0, 0) == CELL_FS_SUCCEEDED)
{
if(cellFsOpen(dst, CELL_FS_O_CREAT | CELL_FS_O_TRUNC | CELL_FS_O_RDWR, &fd_dst, 0, 0) == CELL_FS_SUCCEEDED)
{
ret = CELL_FS_SUCCEEDED;
while (ret == CELL_FS_SUCCEEDED)
{
ret = cellFsRead(fd_src, buffer, sizeof(buffer), &nread);
if(ret != CELL_FS_SUCCEEDED || !nread) break;
ret = cellFsWrite(fd_dst, buffer, nread, &nrw);
}
cellFsClose(fd_src);
cellFsClose(fd_dst);
cellFsChmod(dst, 0777);
}
else
cellFsClose(fd_src);
}
Thank you Aldo
Looks like it's working properly now :)
Tested again and the same thing happens: they copy correctly, but on the next rebootS, both source and destination gets 0KB . It seems the error occurs when the file already exists.
I don't want to check if they exist because I've seen packages that may include some of the files. So, I want to ensure mine are copied.
Do you have a solution in mind? or may i need to delete them before copying it on everyboot?
As you're copying the files from hdd0 to hdd0 you can use syscall 810 => sysLv2FsLink(file1, file2);
static int sysLv2FsLink(const char *oldpath, const char *newpath)
{
system_call_2(810, (u64)(u32)oldpath, (u64)(u32)newpath);
return_to_user_prog(int);
}
It's faster, links don't take much disk space. The unique downside is that if you modify the copy, the original is modified too.
I was just about to ask you about the symbolic links as I was thinking of adding in the XMBM+ team installer.
Thank you, Aldo. It's working, and the issue is gone.
Aldo, sorry for asking it here and it's not releated to webMAN at all, but i'm modding HEN and i added a copy command, but it is not working as intended
`int filecopy(const char src, const char dst) { int fd_src, fd_dst, ret; char buffer[0x1000]; uint64_t nread, nrw; CellFsStat stat;
}
static void copy_files(void) { CellFsStat stat;
}`
If the destination files don't exist, both the source and destination files end up being 0 bytes. Do you have any idea why?