Hello programmers,
I have a toolbox that's often working with a FILE * to access files
and the lot.
Recently, need has arisen to look at the filename of a file when I
only have a FILE *. I know I could be passing the filename from the
calling function, but since I don't know which entry to the toolbox I
took (e.g. toolbox-functions calling each other) it would be far
preferable
to query the filename of the file from the FILE * pointer that I
have.
Oh, and of course I'd need to find out if FILE * points to an actual
file or maybe something else.
Does anyone know how to do this?
Thanks in advance,
regards,
Pelle. 5 1825
On Sep 12, 2:23 pm, Pelle <pelle1...@gmx.dewrote:
Hello programmers,
I have a toolbox that's often working with a FILE * to access files
and the lot.
Recently, need has arisen to look at the filename of a file when I
only have a FILE *. I know I could be passing the filename from the
calling function, but since I don't know which entry to the toolbox I
took (e.g. toolbox-functions calling each other) it would be far
preferable
to query the filename of the file from the FILE * pointer that I
have.
Oh, and of course I'd need to find out if FILE * points to an actual
file or maybe something else.
Does anyone know how to do this?
Not possible in standard C.
Jacob Navia maintains a compiler that offers this as an extension.
<http://www.cs.virginia.edu/~lcc-win32/>
There's possibly other compilers with such extensions. Discussing
those extensions, or the compilers here is off-topic.
Pelle wrote:
>
I have a toolbox that's often working with a FILE * to access
files and the lot. Recently, need has arisen to look at the
filename of a file when I only have a FILE *. I know I could be
passing the filename from the calling function, but since I don't
know which entry to the toolbox I took (e.g. toolbox-functions
calling each other) it would be far preferable to query the
filename of the file from the FILE * pointer that I have.
It is not possible. Unix and Unix clones are one of the major
areas running C programs. The file system is such that the file
name can disappear, or be changed, while the file is open. The
program using the file never knows about these details, and
functions correctly.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
Dear all,
thank you for taking the time to shed some light on the problem as
well as highlighting additional problems that arise with it. I think
I'll have to skip on this one - since I'm not looking for a compiler-
specific way to do this.
Anyway,
thanks for your time and help, it's been appreciated!
Regards,
Pelle.
On 15 Sep, 09:41, Pelle <pelle1...@gmx.dewrote:
Dear all,
thank you for taking the time to shed some light on the problem as
well as highlighting additional problems that arise with it. I think
I'll have to skip on this one - since I'm not looking for a compiler-
specific way to do this.
Anyway,
thanks for your time and help, it's been appreciated!
Note the poster who posts under the name "Richard" sometimes
gives good advice and sometimes merely knocks other people and
generally tries to provoke a reaction.
Today he is having a troll day so just ignore him.
--
Nick keighley
Nick Keighley wrote:
>
.... snip ...
>
Note the poster who posts under the name "Richard" sometimes
gives good advice and sometimes merely knocks other people and
generally tries to provoke a reaction.
Today he is having a troll day so just ignore him.
He posts as "Richard<rg****@gmail.com>" (without the quotes), if
you want to PLONK his annoyances.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: rxl124 |
last post by:
Hi,
quick question,
how would you assign a contents to file in perl
i was thinking
$filename=`echo newvalue > filename`;
|
by: dipique |
last post by:
Hey all, my name is Dan and I'm brand new to C#; all my previous
programming has been in VB6, so this is quite a change. I'd like to
read to and write from a simple text file that's in the app...
|
by: Martin Joergensen |
last post by:
Hi,
I have some files which has the following content:
0 0 0 0 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 0 0 0 0
|
by: Peter Thorne |
last post by:
I am a perl newbie who is trying to write a script to automate a
task.
I have a large collection of compressed archives (mostly .tar.gz,
tar.bz2, tar.Z, .tgz etc). This are stored in a number...
|
by: Rob |
last post by:
I want to copy files from one folder to another... but only if it is a
".txt" file...
Below should work, but how would you filter on ".txt" files only ?
Thanks !
Dim fileEntries As String()...
|
by: Arpan |
last post by:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls.
Using the FileUpload control, I want to give users the provision to
move & delete files that DO NOT exist in C:\Inetpub\wwwroot...
|
by: ArwaAbood |
last post by:
I want to upload file using the following code to make the form:
<html>
<head>
<script type="text/javascript">
function redirect()
{
alert(msg+" want to add new file");
...
|
by: lyne_asp |
last post by:
Hello,
PLease help me to change the filename of uploaded file, here is my code...
For Each File In Uploader.Files.Items
'Save the file to Disk
Dim Folder
Folder = "UploadedFile/"
|
by: cassbiz |
last post by:
Could use some help here.
This script is carrying over an image just fine but the text isn't coming over. can you see why it is not working????
from the form I want to carry over two lines of...
|
by: blazedaces |
last post by:
I'm designing a GUI for autonomous robot interaction, but that's not so important. To figure out the ins and outs of a certain aspect of PyQt I usually just do what I did when I learning Qt, I grab...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| | |