utimes() usage.. does it work?
utimes() usage.. does it work?
I was trying to use utimes() to set the last modified date on a file, does this command not work on the PSP? I see we have times.h in the SDK but I keep getting an undefined reference to utimes() even though I'm including the proper headers...
Does anyone else have any advice on using utimes() for the PSP?
Does anyone else have any advice on using utimes() for the PSP?
Last edited by framerate on Sun Mar 05, 2006 1:52 pm, edited 1 time in total.
Or perhaps somebody has another way to edit the last modified date of a file using straight C?
Something just the equivalent of "touch"ing the files...
Here's the linux equiv.. doesn't seem to work on my PSP though unfortunately...
Something just the equivalent of "touch"ing the files...
Here's the linux equiv.. doesn't seem to work on my PSP though unfortunately...
Code: Select all
struct timeval times[2];
int main() {
utimes("./file.txt", times);
}
-
- Posts: 13
- Joined: Fri Jan 06, 2006 5:44 pm
Only thing I can think of (and this may be assuming little of you) - Are you sure that you're including PSP's sys/types.h and utime.h, and NOT your *nix header files?framerate wrote:Or perhaps somebody has another way to edit the last modified date of a file using straight C?
Something just the equivalent of "touch"ing the files...
Here's the linux equiv.. doesn't seem to work on my PSP though unfortunately...
Code: Select all
struct timeval times[2]; int main() { utimes("./file.txt", times); }
I'll look into this tomorrow with code. But my dev machine's down for the night.
I keep thinking it has to be something simple... maybe a typo since I was coding the whole app in one sitting...
My dev machine is in my office, so I can't work on it tonight... I'm hoping it's just something simple... I took a look at the psp headers and maybe utimes isn't set up for use on the PSP?
Also, I guess using "utimes()" just needs time.h as a header, where utime() - without the s - needs utime.h and types.h. Perhaps one is set up for use on the PSP without the other?
If anyone has any other suggestions to what could be the problem, let me know. I'll be taking another look at the source tomorrow or Monday.
Thanks guys..
My dev machine is in my office, so I can't work on it tonight... I'm hoping it's just something simple... I took a look at the psp headers and maybe utimes isn't set up for use on the PSP?
Also, I guess using "utimes()" just needs time.h as a header, where utime() - without the s - needs utime.h and types.h. Perhaps one is set up for use on the PSP without the other?
If anyone has any other suggestions to what could be the problem, let me know. I'll be taking another look at the source tomorrow or Monday.
Thanks guys..
I don't think utimes is actually implemented cause noone worked out how to use chstat to do it, maybe I will do it at some point in the future :)
Of course if you want use sceIoChstat directly, I think you create a SceIoStat structures with the times in it, then call sceIoChstat(file, bitmask) where bitmask can be 0x8 for creation time, 0x10 for access time and 0x20 for modification time, probably ;)
Of course if you want use sceIoChstat directly, I think you create a SceIoStat structures with the times in it, then call sceIoChstat(file, bitmask) where bitmask can be 0x8 for creation time, 0x10 for access time and 0x20 for modification time, probably ;)
Thanks TyRaNid.TyRaNiD wrote:I don't think utimes is actually implemented cause noone worked out how to use chstat to do it, maybe I will do it at some point in the future :)
Of course if you want use sceIoChstat directly, I think you create a SceIoStat structures with the times in it, then call sceIoChstat(file, bitmask) where bitmask can be 0x8 for creation time, 0x10 for access time and 0x20 for modification time, probably ;)
I was looking into using Stat, but it turns out I'm an idiot! The purpose of this was so I could run an application on my PSP and have it reorder my corrupted icons to the bottom without renaming them/hiding them (for program compatibility). I managed to just read/write a file to change the last modified date of the folder but alas the order is still the same. So my assumption that the PSP ordered the memory card list by last modified is incorrect.
Do you have any information to what it DOES order the list by? I know it's the last one you "dragged" on, but what does this mean if it's not "last modified"? Is it date created? Does date created change when you move from local harddrive to PSP? Or access time (although I thought that was update everytime a file is "accessed" i.e. running an eboot)
This is driving me nuts now =)
Any info would be appreciated. The program is done except not "doing" anything heh. As soon as I can figure out how Sony organizes it (and how to change it) I'll be a very happy coder.
Any more help is greatly appreciated!
I believe that you can't change the mod time of a folder by changing its contents, at least on the PSP.
A simple, kludgy way of doing it is to rename the folder, create a new one with the original name, and then copy the old contents back into it.
Sorting is by last-modified time, I thought, and using a common-or-garden 'touch' utility will change the order. Perhaps it is creation time though, and perhaps the touch default is to hit a number of timestamps at once.
As Tyranid said, the sceIoChStat constants generally seem to match standard FAT / DOS constants (I seem to remember that the read-only etc. attributes do, at least), so the most effective method would be to find the right constants and write a custom touch function using those.
A simple, kludgy way of doing it is to rename the folder, create a new one with the original name, and then copy the old contents back into it.
Sorting is by last-modified time, I thought, and using a common-or-garden 'touch' utility will change the order. Perhaps it is creation time though, and perhaps the touch default is to hit a number of timestamps at once.
As Tyranid said, the sceIoChStat constants generally seem to match standard FAT / DOS constants (I seem to remember that the read-only etc. attributes do, at least), so the most effective method would be to find the right constants and write a custom touch function using those.
Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you!
The PSP Homebrew Database needs you!
Well I did it by connecting it to my G5 and changing the last modified that way, and the file is STILL not at the top of my list. (Top is still the last one I dragged over...)Fanjita wrote:I believe that you can't change the mod time of a folder by changing its contents, at least on the PSP.
That's pretty much what I was going to try, but it seems last modified IS NOT how they're sorting...Fanjita wrote: A simple, kludgy way of doing it is to rename the folder, create a new one with the original name, and then copy the old contents back into it.
I thought this too, but it "appears" to not be the case. I'm gonna play with Creation time today...Fanjita wrote: sorting is by last-modified time, I thought, and using a common-or-garden 'touch' utility will change the order. Perhaps it is creation time though, and perhaps the touch default is to hit a number of timestamps at once.
Any other suggestions are apprecaited.
Thanks Fanjita, also, for all the great work you've done for the scene.