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

File exist

Hi all
Can anyone tell me how can I check that a file exist or no.I mean when
you use this commands
FILE *fp;
if(!fp)
//Could not open the file
doen't show why it can not open it,may be the file doesn't exist.Now
tell me what should I do!
Thanks

Apr 16 '06
52 7434
Walter Roberson wrote:
In article <e2*********@news2.newsguy.com>,
Michael Wojcik <mw*****@newsguy.com> wrote:
[OT]
An SD filesystem could include
filesystem metadata in such a way that for a given message, there
might exist a key which produced that message plus metadata that
meant "read only" to the filesystem, but no key shorter than the
message itself which produced the message plus "read/write" metadata,
so in effect the file could only be opened read-only.
I don't see where the restriction to "no key shorter" would come in,
nor the relevance of that length to "in effect" make the file read-only?
If you had said "no key that did not include the message itself"
perhaps, but even then it doesn't sound right.

If I have a file on a SD filesystem that currently decodes to
1 byte, and I have a read-write key to it, then the extra 1 byte
you would impose is not a meaningful expansion of key space
sufficient to "in effect" make the file read-only. But once I
have a read-write key to the file and I write (say) 1 megabyte
there, the read-write keysize is not suddenly going to bloom
to more than a megabyte: the read-write key would stay the same.


It's possible that the key will grow, similar to an autokey cipher,
although more secure.
It seems to me that any restriction that forced keys to be
larger than the files would impede the deniability. Isn't it the
case that for SD, -every- key should get -something-? If so,
then every read-write key would, in your "no shorter" proposal,
map through SD to a shorter value -- but that would, in effect,
be a compression function, and by the pigeon-hole principle
you can't have a compression function which uniquely maps every input
to a shorter output.


Most compression algorithms eliminate redundancy in texts; by replacing
the repeated work "and" or repeated byte sequence "te se" with a single
byte, all information is retained and therefore the compression does
retain all information.

As I'm typing this, I realize that my method of compression is not an
"algorithm" in the mathematical sense, because it can't be expressed as
a series of formulas (or can it?). So, you're point still stands.
Apr 24 '06 #51
In article <yT43g.66152$7a.42118@pd7tw1no>,
Andrew Poelstra <ap*******@shaw.ca> wrote:
Walter Roberson wrote:
[OT] It seems to me that any restriction that forced keys to be
larger than the files would impede the deniability. Isn't it the
case that for SD, -every- key should get -something-? If so,
then every read-write key would, in your "no shorter" proposal,
map through SD to a shorter value -- but that would, in effect,
be a compression function, and by the pigeon-hole principle
you can't have a compression function which uniquely maps every input
to a shorter output.
Most compression algorithms eliminate redundancy in texts; by replacing
the repeated work "and" or repeated byte sequence "te se" with a single
byte, all information is retained and therefore the compression does
retain all information.


[Going further OT]

I am not a compression expert, but I have studied the subject and
hung around in comp.compression for a few years.

The heart of compression turns out not to be the elimination of
redundancy: that's an optimization.

A function is a compression function if and only if for at least one of
its inputs, the output is "shorter" than the input. The compression
function is "lossless" if the function is one-to-one, and "lossy" if
the function is not one-to-one.

There does not need to be a "formula" or "algorithm" for the
compression function: it can be a pure function in the mathematical
sense where a function is a set of tuples mapping a Domain to a Range
and that the tuples can be arbitrary.

It may sound pretty useless to have a compression function that only
compresses one input, but imagine that the corpus to be compressed
consists of data that is ten million times more likely to be that
particular input: you can see that that seemingly useless compression
function might be just the thing *for that particular input data*.

It is not possible to construct a compression program that compresses
*every* arbitrary input: by the pigeon-hole principle, if one is
operating over an unrestricted input domain, then if some input is
compressed then at least one output must be an expansion.

The goal of people who write generalized compression programs is have
the program compress inputs that likely to be "interesting" to humans,
and to postpone the expansion to inputs that are unlikely to be of
interest. It so happens that humans tend to be "interested" in inputs
that contain a fair bit of redundancy and so redundancy-elimination
algorithms tend to be fairly prominent, but such algorithms, though
very important, are not actually the foundation of compression theory.
--
There are some ideas so wrong that only a very intelligent person
could believe in them. -- George Orwell
Apr 24 '06 #52

In article <e2**********@canopus.cc.umanitoba.ca>, ro******@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
In article <e2*********@news2.newsguy.com>,
Michael Wojcik <mw*****@newsguy.com> wrote:
[OT]
An SD filesystem could include
filesystem metadata in such a way that for a given message, there
might exist a key which produced that message plus metadata that
meant "read only" to the filesystem, but no key shorter than the
message itself which produced the message plus "read/write" metadata,
so in effect the file could only be opened read-only.


I don't see where the restriction to "no key shorter" would come in,
nor the relevance of that length to "in effect" make the file read-only?


I just wanted to specify a stronger condition. Filesystems are a
compression mechanism: they let you substitute a shorter message
(the location of the file) for a longer one (the file itself). In
specific instances, the file may be shorter than the message that
specifies its location, but in general this holds for a majority
of cases. Consequently, I was indicating that it didn't matter if
there was a key longer than the message that didn't satisfy the
condition for read-only access.

Put another way, if the necessary key is larger than the file, you
might as well just carry around the file, and forget about the
filesystem entirely, so that case isn't interesting. And since
typical SD designs let you create any message no longer than the size
of the filesystem, by finding a suitable key, it's possible that the
implementation would reject any key over a certain size, on the
grounds that "real" keys used in practice would be kept to a
managable length. (The deniability aspect can be maintained to a
sufficient level to meet a given threat model even in this case by
setting the maximum key length high enough, provided the threat model
doesn't require absolute deniability.)

On reflection, though, this may not be an interesting distinction.
For one thing, the compression function of a filesystem is really the
mapping between the location of the file and the pair consisting of
the set of all possible valid messages contained in that file and
the index of the current message.

It's since occurred to me that a more relevant issue is what the
distinction between "read-only" and "writable" means in this context.
For example, does writable imply readable? If not, how is write-
only access implemented? (This is a different question from a
possible implementation of stdio, since the latter could simply
ignore readability when opening write-only.)

In practice, a more suitable way of imposing write protection for an
SD filesystem would probably be to keep file verifiers separately, so
they can't be captured as part of the filesystem and used to defeat
deniability.

Oh well. This is really a sci.crypt topic, and to be honest just
something I keep an idle eye on, so I might be talking complete
rubbish about the possibility of imposing access restrictions in a
case like this.

--
Michael Wojcik mi************@microfocus.com

I do not care to listen; obloquy injures my self-esteem and I am
skeptical of praise. -- Jack Vance
Apr 28 '06 #53

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

Similar topics

10
by: lamar_air | last post by:
I have a python script and i want to delete a file on my computer c:\....\...\.. .txt what's the script to do this? I know how to write to files but i also need to know how to delete a file.
2
by: Chris Fink | last post by:
I am using the System.IO.File class to determine if a file exists on a network share. The File.Exists method keeps returning false, even though the file does exist. The MSDN documentation...
4
by: Mike | last post by:
Hi, I am looking for function in .Net library that let me know if exist any file if I specified template. Eg: I specify "*.txt" and if any file (1.txt, 2.txt, .. ) exists then I can get True...
1
by: Tim Failes | last post by:
This seems a trival question, but I cannot get it to work properly... Essentially my question is, how can I create a text file, and guarantee it is given the current date/time as the Creation Time?...
3
by: tshad | last post by:
I have a function that downloads a file to the users computer and it works fine. The problem is that I then want the program to rename the file (file.move) to the same name plus todays date. ...
26
by: Army1987 | last post by:
Is this a good way to check wheter a file already exists? #include <stdio.h> #include <stdlib.h> int ask(const char *prompt); typedef char filename; int main(int argc, char *argv) { FILE...
7
by: sprash | last post by:
Newbie question: I'm trying to determine if a file physically exists regardless of the permissions on it Using File.Exists() returns false if it physically exists but the process does not...
3
by: brook | last post by:
hey all - i´m new to php and having trouble writing a simple code which should create a file. here is the most simplified version: <?php $content = "my content"; $path = "test.txt";...
65
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
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...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.