473,383 Members | 1,855 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,383 software developers and data experts.

fopen ("file on shared drive","w+") doesn't work on 2nd call using Windows LabView DDL

Hello,

I have a shared drive on SGI, Linux, and Windows.

A second call to fopen doesn't create the file if it has been
deleted.

I would like to use fopen for its pointer return value to solve this.

What is the best way to fix this problem?

The reason I want to do this is I do not want to exit completely
from LabView and then re-enter it to create the file!

I talked to my system person and he said something "like" this. That it

is a caching problem. Windows has the file in cache memory. All
references to it affect the cached file. You can do fopens (NULL not
returned, and errno not set), reads, and writes, but they do not
affect the file in question on the shared drive. He went on to say that

I have to use "creat" and change all read/writes appropriately.

Thank you,
Christopher Lusardi

Nov 15 '05 #1
7 3346
I posted DDL on the subject line when I should have typed DLL.

Sorry,
Christopher Lusardi

Nov 15 '05 #2
cl********@aol.com wrote:

Hello,

I have a shared drive on SGI, Linux, and Windows.

A second call to fopen doesn't create the file if it has been
deleted.
I believe this is really platform-specific given your description.
I don't know if it's a Linux issue of a Windows issue.

Is the first FILE* still open? Linux lets you delete files that
are still open, Windows does not. What happens when Windows has
a Linux file open, one can only guess. I doubt the standard says
anything about this, beyond "undefined" or "implementation specific".

[...] I talked to my system person and he said something "like" this. That it

is a caching problem. Windows has the file in cache memory. All
references to it affect the cached file. You can do fopens (NULL not
returned, and errno not set), reads, and writes, but they do not
affect the file in question on the shared drive. He went on to say that

I have to use "creat" and change all read/writes appropriately.


If fopen() returns something other than NULL, then errno won't be
set because it didn't fail.

If the first FILE* is still open, I would venture to guess that your
"system person" may be on to something. The file is still open, so
it may be that Windows doesn't bother asking the remote system to
re-open the file, instead opting to duplicate the existing handle.

If the first FILE* was closed before the file was removed, then it
may be a bug in Windows, allowing you to open a file which is no
longer there. (Though one could claim my first scenario is a bug
as well.)

You'll probably have to ask a Windows newsgroup for further details.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Nov 15 '05 #3
# I talked to my system person and he said something "like" this. That it
#
# is a caching problem. Windows has the file in cache memory. All
# references to it affect the cached file. You can do fopens (NULL not
# returned, and errno not set), reads, and writes, but they do not
# affect the file in question on the shared drive. He went on to say that

I suppose Windows inability to handle something as simple as
fopen/fclose/fopen shouldn't be surprising.

# I have to use "creat" and change all read/writes appropriately.

You might fdopen available that can turn a system specific
file designator into a FILE* pointer.

On Unix it could be something like
int fd = open(path,O_CREAT|O_WRONLY,0755);
FILE *fp = fdopen(fd,"w");

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Raining down sulphur is like an endurance trial, man. Genocide is the
most exhausting activity one can engage in. Next to soccer.
Nov 15 '05 #4

Kenneth Brody wrote:
Is the first FILE* still open?


The file has been closed before the second fopen.

Will doing a creat with an unbuffered option help?

Christopher Lusardi

Nov 15 '05 #5
Solved it by myself, see below.

SUMMARY
C and C++ file operations, by default, perform their own data caching.
This caching is in addition to the disk caching done by the operating
system. Under certain conditions it may be necessary to ensure your
data is fully flushed to the disk. This article explains how to ensure
that your data is properly flushed to the disk.

MORE INFORMATION
To flush the C runtime buffers, you need a call to fflush for files
that are opened with fopen or a call to the flush function for C++
ofstream objects. Flushing the operating system's disk cache is a
little more difficult; it depends on the operating system in use.

16-bit Operating Systems - MS-DOS or Windows 3.1
In MS-DOS or Windows 3.1 running Smartdrv.exe version 4.0 or later, you
have two choices. You can use the _commit C runtime function or link
with Commode.obj and use the fflush C runtime function.

32-bit Windows Operating Systems
In 32-bit versions of Windows, the operating system has built-in disk
caching. The only way to force a file to be flushed to disk is by
linking to Commode.obj.

Commode.obj is designed to affect the way the C Runtime handles files.
When you link to this .obj file, a call to the C runtime function
fflush also forces the operating system to flush its cache to disk,
making the call to _commit unnecessary.

Christopher Lusardi

Nov 15 '05 #6
cl********@aol.com wrote:

Kenneth Brody wrote:
Is the first FILE* still open?
The file has been closed before the second fopen.


Was it closed before the file was deleted?

If so, I'd say it's a bug in Windows. (There's no reason for it to
be caching anything about a remote file that's closed.)

If not, I'd say it's simply the way Windows handles deleting of files
that are still open. (Remember, Windows won't permit this if the file
were on a Windows box, so it may not be able to handle it when the file
is on a remote *nix box.)
Will doing a creat with an unbuffered option help?


Dunno. Now you're getting into things you would need to ask on a Windows
newsgroup.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:Th*************@gmail.com>

Nov 15 '05 #7
cl********@aol.com writes:
[...]
To flush the C runtime buffers, you need a call to fflush for files
that are opened with fopen or a call to the flush function for C++
ofstream objects. Flushing the operating system's disk cache is a
little more difficult; it depends on the operating system in use.


Just keep in mind that fflush() is undefined for input streams.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 15 '05 #8

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

Similar topics

1
by: Beryl Small | last post by:
I have a web application in Visual Studio.Net 2003. On the click event of a button on my .aspx page, I use the following FileCopy SourceFile, DestinationFil the Sourcefile is on a mapped drive...
2
by: Bill N. | last post by:
Using VB .Net 2003 Standard Edition. This simple form has a "File in Use" problem while the executable is running. Created this simple program to make sure that I hadn't done something in my...
10
by: Dieter Salath? | last post by:
Hi, in our webpage, a user could open a windows explorer to his temp directory with a simple link and usage of the file protocol: <a href="file://C:\temp" target="_blank">C:\temp</a> This...
1
by: clusardi2k | last post by:
Hello, I have a shared drive on SGI, Linux, and Windows. The fact that I'm using a shared drive may be mute information. The problem is within the same program a second call to fopen does not...
6
by: Ross | last post by:
MyWebProject.MyWebForm1.someset.somedata is a datatable within a dataset. Displays quite nicely, too. Now I want to use the same data in MyWebProject.MyWebForm2. Being a old, er, experienced Java...
1
by: skumar | last post by:
whenever a user log in in my web application, i am trying to Map a drive "V:/" to a network path which is unique to each user(but i have to map to drive V:/ only). As any number of users can login to...
1
by: Shark Bait | last post by:
Hi, I have a web site that I am creating locally on my workstation's "C" drive. I have a reference in my web.config to a resource file (it contains global keys) using "\" as the root. Everything...
1
by: David Sanschagrin | last post by:
(I previously posted this problem on vb.general.discussion but I've been told that this question is more related to VB.NET than VB6 and so that I should post that here.) I'm trying to call a...
4
by: Luc The Perverse | last post by:
Hi - I have very little C# programming experience. I am making a software product which calls for an interface almost identical to Windows Explorer - and I wondered if mounting a "virtual drive"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.