Solved

File Handles in Mixed Language Programming

Posted on 1998-08-03
7
209 Views
Last Modified: 2013-11-08
I need a way to figure out how to obtain a listing of all files and there associated handles that a program has open at any given time during program execution.  I need this because I am opening, reading, writing, and closing my files in Fortran, but I am locking and unlocking records in these files using C++ (the original LOCKING routine was eliminated by Microsoft when they created Fortran Powerstation).  Anyway, I'm using Microsoft Developer Studio in conjuction with Visual C++ and Fortran Powerstation.  There is no way in Fortran that I know of to obtain the handles of the files that it opens.  Is there any other way I can get these handles?  This will be a tough question, I think.  It must be stored somewhere in some type of table, no?
0
Comment
Question by:ardolino
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 2

Expert Comment

by:JYoungman
ID: 1169302
My FORTRAN is a bit rusty now but it seems to me that the most convenient approach would probably be to WRITE your data into CHARACTER*(*) variables and then pass these to a C++ routine to do the actual I/O, and hence avoid opening the files from FORTRAN.  I know it's sometimes difficult to pass a CHARACTER*(*) to another language, so you may have to use a CHARACTER*(nnn) instead.

If this just isn't possible, then I suggest you use two files.  One ('FOO.DAT') is the one against which you do I/O from FORTRAN, and the other ("FOO.LCK") is the one against which you do the locking and unlocking from C++.  

0
 

Author Comment

by:ardolino
ID: 1169303
My problem is that I am doing a mass conversion of over 1000 programs written in FORTRAN that already having external function calls to lock and unlock records in a file, but all of the programs open, read, write, and close the files directly.  If I could just obtain the handle of the file, I can replace the lock and unlock functions with c++ routines that can actually lock and unlock the files.  (The original FORTRAN lock and unlock routines used the FORTRAN LOCKING command (no longer available)).  If I can't get the handle, then I can always work something out with using two files, but if there is a way to get the handle, it would be a lot easier for me, even if getting the actual handle may be difficult.  There has to be a way to get it, no?
0
 
LVL 2

Expert Comment

by:JYoungman
ID: 1169304
Yes, I assume there is *some* way to get it.  I don't have a copy of PowerStation here, and I'm currently booted to Linux, so I can't even search the MSDN library (since the MSDN library program only runs under Windows).  I could tell you how to do it under Linux with g77 if you like :-)    But seriously, I don't know how to get the file handle and don't have access to the relevant reference material at the moment.

Does this locking need to take place between machines over a network, or just on one machine?


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ardolino
ID: 1169305
I found a utility called File Monitor for Win95 and WinNT - it has source code, but I'm having a little trouble understanding it.  I'll figure it out, though - it does what I want to do.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1169306
Can you post the URL where this utility is obtainable from?
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 total points
ID: 1169307
FindFirstChangeNotification and FindNextChangeNotification allow you to monitor changes to a directory tree from a C++ program.  Assuming you know where the Fortran program writes files, the C program can monitor this area and take corresponding action (placing the locks for example).


0
 
LVL 22

Expert Comment

by:nietod
ID: 1169308
locking and unlocking need to be done synchronously.  The change notification system is goig to opperate asynchronously.  VERY asynchronously.  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question