 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
johnmph
Joined: 23 Jul 2005 Posts: 119
|
Posted: Sun Mar 05, 2006 12:38 am Post subject: file name <- file descriptor |
|
|
Hello, Is this possible to know the name of a file with it's file descriptor ?
Thanks |
|
| Back to top |
|
 |
DustinFraze
Joined: 06 Jan 2006 Posts: 13
|
Posted: Sun Mar 05, 2006 3:13 pm Post subject: Re: file name <- file descriptor |
|
|
| johnmph wrote: | Hello, Is this possible to know the name of a file with it's file descriptor ?
Thanks |
...why?
If you've got a file descriptor, you know the file name. You had to know the file name to open a descriptor to it.
Chances are you're trying to do something you don't won't *really* want to do, or you're going about doing it the wrong way.
None-the-less, if you still want to go for it, give fstat() a try. Between fstat, and some direct.h work,(specifcally, opendir(), and recursing through the dir, trying to match the file inode returned by fstat with an inode in a structure returned from opendir() ) you could get it done. It wouldn't be simple, or proper, or even smiled upon, and in the end, there is a severe deficit of reasons to do such an operation, but if you're talented enough to string together the commands outlined above to working code, then I'm going to assume you're intelligent enough to know why this is a "bad idea", and that you've got a good reason for it.
Perhaps, however, if that's not the case, you instead explain the situation you're in, and what you want to *ultimately* acomplish. Too many times people ask very pointed, complicated questions, when the same result can be determined by a simple alternative. |
|
| Back to top |
|
 |
johnmph
Joined: 23 Jul 2005 Posts: 119
|
Posted: Sun Mar 05, 2006 10:42 pm Post subject: Re: file name <- file descriptor |
|
|
| DustinFraze wrote: | | johnmph wrote: | Hello, Is this possible to know the name of a file with it's file descriptor ?
Thanks |
...why?
If you've got a file descriptor, you know the file name. You had to know the file name to open a descriptor to it.
Chances are you're trying to do something you don't won't *really* want to do, or you're going about doing it the wrong way.
None-the-less, if you still want to go for it, give fstat() a try. Between fstat, and some direct.h work,(specifcally, opendir(), and recursing through the dir, trying to match the file inode returned by fstat with an inode in a structure returned from opendir() ) you could get it done. It wouldn't be simple, or proper, or even smiled upon, and in the end, there is a severe deficit of reasons to do such an operation, but if you're talented enough to string together the commands outlined above to working code, then I'm going to assume you're intelligent enough to know why this is a "bad idea", and that you've got a good reason for it.
Perhaps, however, if that's not the case, you instead explain the situation you're in, and what you want to *ultimately* acomplish. Too many times people ask very pointed, complicated questions, when the same result can be determined by a simple alternative. |
Thank you for fstat / opendir solution and obviously, I don't have access to the file name. |
|
| Back to top |
|
 |
|
|
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
|