Solved

File Handles in Mixed Language Programming

Posted on 1998-08-03
7
207 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
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sumDigits  challenge 7 91
rhino JavaScript import, load 25 84
CONDITIONAL MAX STATEMENT IN T-SQL 3 59
Autosar OS Multicore Share Resources confusion ? 2 40
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…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

809 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