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

question on files

how can u lock files in c
Aug 31 '07 #1
2 962
dmjpro
2,476 2GB
how can u lock files in c
What do you mean by that?
You want to lock the File using Password or want to give some privilege Access to specific Users.
What do you want?
And look, when you are doing File Handling in any Language then remember One thing what OS supported only you can do that.
By the way, What OS you are using?

Kind regards,
Dmjpro.
Aug 31 '07 #2
JosAH
11,448 Expert 8TB
how can u lock files in c
If all parties can play by the same rules there exists an extremely easy file
locking scheme: suppose a file named "foo" is a shared resource.

1) Try to create a file named "foo.lck"; if this fails, the file "foo.lck" already exists
and is supposed to contain the PID of the process that created it.

2) if "foo.lck" didn't exist before, it exists now and write the process' PID to the
file and close it.

3) do whatever must be done with "foo" and remove "foo.lck" afterwards.

If step 1) failed (i.e. "foo.lck" existed already), check if the process that created it
still exists (its PID is in the .lck file). If the process isn't there, it must've died
prematurely; change the PID in the .lck file and continue with step 3). If the
process still exists it is working on file "foo" so the file is locked; all your process
can do is wait.

kind regards,

Jos
Aug 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
10
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
2
by: cjl | last post by:
PHPers: I am a total beginner, so please excuse my very simple question. I have been playing with PHP on Windows XP, and mostly using Notepad2 (http://www.flos-freeware.ch/notepad2.html) for...
13
by: Eric_Dexter | last post by:
All I am after realy is to change this reline = re.line.split('instr', '/d$') into something that grabs any line with instr in it take all the numbers and then grab any comment that may or may...
7
by: James | last post by:
Today my friend ask me a question about setting logsecond to -1. The following sentences were copied from DB2 InforCenter: "By setting logsecond to -1, you will have no limit on the size of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.