473,394 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

File pointer to file handle

I'm trying to figure out if there's a function that takes a file pointer
(FILE *) and will return a HANDLE type ... I'm trying to modify some code
and I've looked everywhere to no avail.

Thanks
--
Apollyon


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 14 '05 #1
5 6450
Apollyon <ab*****@loopback.edu> scribbled the following:
I'm trying to figure out if there's a function that takes a file pointer
(FILE *) and will return a HANDLE type ... I'm trying to modify some code
and I've looked everywhere to no avail.


Seeing as HANDLE is not a standard C type, your question is off-topic
here. Please ask in a newsgroup dedicated to your own operating system.

An answer that would work within the contents of this newsgroup would
be:

#include <stdio.h>
typedef FILE *HANDLE;
HANDLE convert_file_ptr_to_handle(FILE *ptr) {
return ptr;
}

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"C++. C++ run. Run, ++, run."
- JIPsoft
Nov 14 '05 #2
Yes, I know, I had tried there and wasn't getting a very rapid response so I
figured I'd try here too. Oh well.

--
Apollyon

"Joona I Palaste" <pa*****@cc.helsinki.fi> wrote in message
news:c7*********@oravannahka.helsinki.fi...
Apollyon <ab*****@loopback.edu> scribbled the following:
I'm trying to figure out if there's a function that takes a file pointer
(FILE *) and will return a HANDLE type ... I'm trying to modify some code and I've looked everywhere to no avail.


Seeing as HANDLE is not a standard C type, your question is off-topic
here. Please ask in a newsgroup dedicated to your own operating system.

An answer that would work within the contents of this newsgroup would
be:

#include <stdio.h>
typedef FILE *HANDLE;
HANDLE convert_file_ptr_to_handle(FILE *ptr) {
return ptr;
}

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"C++. C++ run. Run, ++, run."
- JIPsoft



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Nov 14 '05 #3

"Apollyon" <ab*****@loopback.edu> wrote in message
I'm trying to figure out if there's a function that takes a file pointer
(FILE *) and will return a HANDLE type ... I'm trying to modify
some code and I've looked everywhere to no avail.

On older implementations you often have low-level, unbuffered IO and
functions like open(), read(), and write().
These are not ANSI, are not supported on all platforms, and are virtually
obsolete on a modern hosted system, because it is no longer possible to get
significant performance increases by messing with the buffering.
If you mix the fopen() family of functions with another IO family then you
risk having problems, such as the stdio functions buffering input so it gets
written in the wrong order.
However if you are determined, there will probably be a function that gets a
"handle" from a FILE *. If not, look at the structure members and one of
them will probably be what you are looking for. However you are now leaving
ANSI C land.
Nov 14 '05 #4
On Sun, 2 May 2004 00:44:59 -0600, in comp.lang.c , "Apollyon"
<ab*****@loopback.edu> wrote:
Yes, I know, I had tried there and wasn't getting a very rapid response so I
figured I'd try here too. Oh well.


the obvious way to do this would be to use some platform-specific functions
to find out the filename from the FILE*, then re-open it using the right
platform-specific function.
However you're going to have to read your compiler docs to find out how to
do that.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 14 '05 #5
Apollyon wrote:

I'm trying to figure out if there's a function that takes a file
pointer (FILE *) and will return a HANDLE type ... I'm trying to
modify some code and I've looked everywhere to no avail.


There is no such thing as a HANDLE type in C, unless you define it
yourself. Some systems have a non-standard function called
"fileno(FILE *)", which you might look up on your system. The
results are no-longer portable, and thus off-topic here.

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Brandon McCombs | last post by:
This may be the wrong group but I didn't see anything for VC++ so I'm trying here. I have a C++ book by Deitel and Deitel that says I can use fstream File("data.dat", ios::in | ios::out |...
5
by: matt dittman | last post by:
I have created a windows service that reads emails from a drop directory and moves them to the appropriate mail folder every 15 seconds. I can move, rename and delete the files as needed, up...
1
by: bissatch | last post by:
Hi, I am currently working on a content management system where a user can fill in a form (title, keywords, link text etc. - all the initial attibutes), which when submitted, will go onto create...
5
by: Pete | last post by:
I having a problem reading all characters from a file. What I'm trying to do is open a file with "for now" a 32bit hex value 0x8FB4902F which I want to && with a mask 0xFF000000 then >> right...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
1
by: Daniel | last post by:
does the windows file handle change? are file handles unique to the whole operating system or just the current directoy? if a file is opened then closed then opened again, does the file handle...
14
by: prasadjoshi124 | last post by:
Hi All, I am writing a small tool which is supposed to fill the filesystem to a specified percent. For, that I need to read how much the file system is full in percent, like the output given...
9
by: junky_fellow | last post by:
Hi, To print the pointer using printf(), we convert it to (void *) . printf("%p",(void *)ptr); My question is how printf() determine which type of pointer is passed to it and prints its value...
9
by: Ron Eggler | last post by:
Hi, I would like to write binary data in a file i open (ofstream) with ios::binary but it keeps failing and it gives me a segmentation fault. What I'm exactly doing: if (isBinary == true) {...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.