473,480 Members | 2,123 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Open file without know the complete name?

nan

Hi all.
Anyone has an idea of how to open a file without know the complete
name of it, without opening the directory (with opendir) and test each
file?

For example, I have this:

1070471736268

and the complete file name is:

1070471736268-E1=E9=ED=F3.txt

Regards and thanks for you comments.

Antonio.
Nov 13 '05 #1
4 8275
In <20***************************************@yahoo.e s> nan <an*******************@yahoo.es> writes:

Anyone has an idea of how to open a file without know the complete
name of it, without opening the directory (with opendir) and test each
file?

For example, I have this:

1070471736268

and the complete file name is:

1070471736268-E1=E9=ED=F3.txt


This cannot be done in standard C, because fopen() doesn't accept
wildcard characters. A directory lookup must be performed, one way or
another, to obtain the complete file name.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #2
On Thu, 4 Dec 2003, nan wrote:

Hi all.
Anyone has an idea of how to open a file without know the complete
name of it, without opening the directory (with opendir) and test each
file?

For example, I have this:

1070471736268

and the complete file name is:

1070471736268-E1=E9=ED=F3.txt

Regards and thanks for you comments.


So you want to open a file name but:

1) you don't know its full name
2) you cannot scan the directory for the file name

Sure, I know that FILENAME_MAX is the longest a file name can be. I can
just iterate through all possible combinations of strings. If I know it
starts with a 13 character string them I want to start with that string
then all strings of length 14, 15, 16, etc. For each filename generated I
would attempt to open the file.

I, personally, would never do this. I'd use an implementation defined way
of scanning the directory.

Your question is equivalent to, "I have a word written on a piece of
paper. It starts with 'pro'. Tell me what the word is but you cannot look
at the piece of paper." This is actually easier because you can use a
dictionary to filter your guesses.

--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@whitehouse.gov
Nov 13 '05 #3
nan wrote:

Hi all.
Anyone has an idea of how to open a file without know the complete
name of it, without opening the directory (with opendir) and test each
file?

For example, I have this:

1070471736268

and the complete file name is:

1070471736268-E1=E9=ED=F3.txt

Regards and thanks for you comments.

Not in C but, if your program is named foo you might invoke it..

$foo 1070471736268*.txt

Your command processor might well present to your program the names of
all the files in the current directory which begin with the number and
have a .txt extension. Think argc and argv.
--
Joe Wright http://www.jw-wright.com
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
Nov 13 '05 #4
In <3F***********@earthlink.net> Joe Wright <jo********@earthlink.net> writes:
nan wrote:

Hi all.
Anyone has an idea of how to open a file without know the complete
name of it, without opening the directory (with opendir) and test each
file?

For example, I have this:

1070471736268

and the complete file name is:

1070471736268-E1=E9=ED=F3.txt

Regards and thanks for you comments.

Not in C but, if your program is named foo you might invoke it..

$foo 1070471736268*.txt

Your command processor might well present to your program the names of
all the files in the current directory which begin with the number and
have a .txt extension. Think argc and argv.


But it might as well not do that. It's Unix shells that typically
expand wildcards on the command line, but most other command processors
don't do it. On some implementations, it is programmer's option (usually
via a global variable or by linking an alternate crt0) whether the C
startup code will do it or not.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 13 '05 #5

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

Similar topics

0
2101
by: Unigroup of New York | last post by:
Content-Type: multipart/mixed; boundary="------------C465DF38DCB38DD2AF7117E0" Lines: 327 Date: Tue, 15 Feb 2005 23:36:38 -0500 NNTP-Posting-Host: 24.46.113.251 X-Complaints-To: abuse@cv.net...
115
13955
by: TheAd | last post by:
At this moment I use MsAccess and i can build about every databound application i want. Who knows about a serious open source alternative? Because Windows will be a client platform for some time, i...
5
2072
by: Saket | last post by:
Hello All, I am want to open a file in C language where in i know the location of the file, but do not know its name. For this what i have done is: - 1) Used system command like and listed...
5
5295
by: Neo | last post by:
Hello: I am receiving a Binary File in a Request from a application. The stream which comes to me has the boundary (Something like "---------------------------39<WBR>­0C0F3E0099" without the...
18
3296
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to...
7
590
by: Defected | last post by:
Thanks all for help, I have tried this code but it's don't work. -------------------------------------------------------------------- Structure typedef struct{ int atomic_number; char...
0
5078
by: mix01 | last post by:
Hi, I am trying to get some VBA code working, but am preplex as to why it does not work. I would really appreciate any level of help. Many thanks, Mix01 Version of the program
38
5029
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
0
7048
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,...
0
6911
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...
0
7050
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,...
0
7091
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...
1
6743
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...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4488
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...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1303
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 ...

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.