473,750 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3372
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 "implementa tion 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_CRE AT|O_WRONLY,075 5);
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_Keit h) 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
2295
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 (s:\) on the server it returns the error "File not found" even though the file is there. The same code in the same place works fine if the file is on the c:\ drive. Same code also works fine with the mapped server drive in .NET if a put it in a...
2
12405
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 code in the "real" project. In the "real" project, One part of the program saves multiple images and another part of the program moves the images to the appropriate directories based on user feedback.
10
60717
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 worked very well a long time, but now it does not work anymore. We use IE6 and Microsoft Windows XP Professional 2002 SP2. I guess it has something to do with new IE security features. Does
1
2118
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 create a file if the file has been deleted. I would like to use fopen for its pointer return value to solve this.
6
1455
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 programmer, I thought I could write this as a member of MyWebForm1: Public Shared Function getSomeData() As DataTable getSomeData = somedata End Function
1
1296
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 the web app at a particular time , i do not know how to do this mapping in the web server I have to map "V:/" drive only because, the ultimate aim is to open a word document which is a mail merge document with reference to Merge data document...
1
2853
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 works fine. When I move it to a test server the mapping to the file no longer works unless I include the drive letter "D". I don't have to reference the drive letter on my workstation why would I have to do it on test? I thought "\" meant: "The root...
1
6782
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 "Public Shared" function in a dll built in VB.NET from a VB6 program. Whenever I try, I get an error saying that the function doesnt exist. I had doubts that the "Shared" in the VB.NET dll could be the problem. I tried to
4
9156
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" would be feasable for me (someone not good at programming) to implement. -- LTP :)
0
9001
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9583
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9396
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9342
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6808
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4888
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3323
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.