473,608 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

search for files

hi there
can any one write a C code that search for files in a directory
without using the windows apis(FindFirstF ile() and FindNextFile())
or even has a small idea on how to do that.
thanks.
Jun 29 '08 #1
30 2045
Jrdman wrote:
hi there
can any one write a C code that search for files in a directory
without using the windows apis(FindFirstF ile() and FindNextFile())
or even has a small idea on how to do that.
thanks.
No.
I use the MSDN library for that purpose.

--
pete
Jun 29 '08 #2
In article <f7************ *************** *******@y21g200 0hsf.googlegrou ps.com>,
Jrdman <ah*********@gm ail.comwrote:
>hi there
can any one write a C code that search for files in a directory
without using the windows apis(FindFirstF ile() and FindNextFile())
or even has a small idea on how to do that.
I would imagine that using the Windows APIs would be fairly useless
on non- MS Windows systems, so if we take it as understood that
people have indeed been able to write code to search for files in
a directory on at least one non- MS Windows system, then the answer
to your question would logically have to be "Yes".
You might find it instructive to read the recent thread "directorie s"
started by 'sid' on June 27th,
http://groups.google.ca/group/comp.l...23538a011bd637
--
Q: Why did the chicken cross the Mobius strip?

A: There were manifold reasons.
Jun 29 '08 #3
"Jrdman" <ah*********@gm ail.comwrote in message news:
can any one write a C code that search for files in a directory
without using the windows apis(FindFirstF ile() and FindNextFile())
or even has a small idea on how to do that.
No.
ANSI C has no directory functions, which at first sight may seem surprising
since there are fucntions to open files from paths.
However on many systems directories can be very large, and can be altered by
other users. This makes it quite difficult to devise a robust interface
which will hold for every system.
Thus you have to use OS-specific functions.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Jun 29 '08 #4
On Jun 29, 1:21*pm, "Malcolm McLean" <regniz...@btin ternet.comwrote :
"Jrdman" <ahmed.bo...@gm ail.comwrote in message news:
can any one write a C code that search for files in a directory
without using the windows apis(FindFirstF ile() and FindNextFile())
or even has a small idea on how to do that.

No.
ANSI C has no directory functions, which at first sight may seem surprising
since there are fucntions to open files from paths.
However on many systems directories can be very large, and can be alteredby
other users. This makes it quite difficult to devise a robust interface
which will hold for every system.
Thus you have to use OS-specific functions.

--
Free games and programming goodies.http://www.personal.leeds.ac.uk/~bgy1mm
yes i know that ANSI C has no directory functions,to make my question
clear,how can i write a function that search for files using a native
C code (without using Windows APIs)i know it's possible to write that
code, the obvious example is the windows APIs
themselves(Find FirstFile() and FindNextFile()) if it's not possible how
these two functions are coded?
Jun 29 '08 #5
In comp.lang.c, Jrdman wrote:
hi there
can any one write a C code that search for files in a directory
without using the windows apis(FindFirstF ile() and FindNextFile())
Technically, with the proper 3rd-party addon, anyone can write this. In
fact, given my current platform, I can definitely write a directory search
program in C (with POSIX extensions) without using /any/ Windows APIs. It
helps that I don't run Windows, of course ;-)

or even has a small idea on how to do that.
thanks.
--
Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------
Jun 29 '08 #6
Jrdman wrote:
yes i know that ANSI C has no directory functions,to make my question
clear,how can i write a function that search for files using a native
C code (without using Windows APIs)i know it's possible to write that
code,
the obvious example is the windows APIs
themselves(Find FirstFile() and FindNextFile()) if it's not possible how
these two functions are coded?
It seems as though:
1 Those functions are your examples of functions
coded in "native c code".
2 You have no idea how those functions are coded.

Am I reading you correctly?

--
pete
Jun 29 '08 #7
Jrdman wrote:
On Jun 29, 1:21 pm, "Malcolm McLean" <regniz...@btin ternet.comwrote :
>"Jrdman" <ahmed.bo...@gm ail.comwrote in message news:
>>can any one write a C code that search for files in a directory
without using the windows apis(FindFirstF ile() and FindNextFile())
or even has a small idea on how to do that.
No.
ANSI C has no directory functions, which at first sight may seem surprising
since there are fucntions to open files from paths.
However on many systems directories can be very large, and can be altered by
other users. This makes it quite difficult to devise a robust interface
which will hold for every system.
Thus you have to use OS-specific functions.

yes i know that ANSI C has no directory functions,to make my question
clear,how can i write a function that search for files using a native
C code (without using Windows APIs)i know it's possible to write that
code, the obvious example is the windows APIs
themselves(Find FirstFile() and FindNextFile()) if it's not possible how
these two functions are coded?
There is no requirement that Windows API functions are coded in C. For
all we know, they're coded in assembler. There are many ways to make
functions available to C without writing those functions themselves in
C, though the techniques are off-topic here.

There is _no_ portable way to do what you're asking. C does not even
acknowledge that directories exist, since C has to work on platforms
that have no concept of directories. Therefore, there is no 100%
portable way to write code that manipulates or even examines directories.

The usual solution when running into problems like this is to create
your own wrapper interface and a few different implementations (with
suitable #ifdef's) that call the native functions. Of course, at that
point your program is only "portable" to the systems that implement one
of the native interfaces you know how to call...

S
Jun 29 '08 #8
On Jun 29, 2:32*pm, pete <pfil...@mindsp ring.comwrote:
Jrdman wrote:
yes i know that ANSI C has no directory functions,to make my question
clear,how can i write a function that search for files using a native
C code (without using Windows APIs)i know it's possible to write that
code,
*the obvious example is the windows APIs
themselves(Find FirstFile() and FindNextFile()) if it's not possible how
these two functions are coded?

It seems as though:
* * 1 * *Those functions are your examples of functions
* * * * *coded in "native c code".
* * 2 * *You have no idea how those functions are coded.

Am I reading you correctly?

--
pete
As i know(i've heard) and i'm not sure that windows APIs are coded in
C and those two functions are part of Windows APIs.if i'm wrong you
can correct me not just tell me that i'm wrong coz this is not
helpfull anymore
Jun 29 '08 #9
On Jun 29, 2:57*pm, Stephen Sprunk <step...@sprunk .orgwrote:
Jrdman wrote:
On Jun 29, 1:21 pm, "Malcolm McLean" <regniz...@btin ternet.comwrote :
"Jrdman" <ahmed.bo...@gm ail.comwrote in message news:
can any one write a C code that search for files in a directory
without using the windows apis(FindFirstF ile() and FindNextFile())
or even has a small idea on how to do that.
No.
ANSI C has no directory functions, which at first sight may seem surprising
since there are fucntions to open files from paths.
However on many systems directories can be very large, and can be altered by
other users. This makes it quite difficult to devise a robust interface
which will hold for every system.
Thus you have to use OS-specific functions.
yes i know that ANSI C has no directory functions,to make my question
clear,how can i write a function that search for files using a native
C code (without using Windows APIs)i know it's possible to write that
code, the obvious example is the windows APIs
themselves(Find FirstFile() and FindNextFile()) if it's not possible how
these two functions are coded?

There is no requirement that Windows API functions are coded in C. *For
all we know, they're coded in assembler. *There are many ways to make
functions available to C without writing those functions themselves in
C, though the techniques are off-topic here.

There is _no_ portable way to do what you're asking. *C does not even
acknowledge that directories exist, since C has to work on platforms
that have no concept of directories. *Therefore, there is no 100%
portable way to write code that manipulates or even examines directories.

The usual solution when running into problems like this is to create
your own wrapper interface and a few different implementations (with
suitable #ifdef's) that call the native functions. *Of course, at that
thanks.but what do you mean by native functions(what functions?)?
point your program is only "portable" to the systems that implement one
of the native interfaces you know how to call...

S- Hide quoted text -

- Show quoted text -
Jun 29 '08 #10

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

Similar topics

1
1697
by: RiceGuy | last post by:
Hi! I'm looking for ideas on what would the best approach to design a search system for a RSS feeds. I will have some 50 RSS feeds (all RSS 2.0 compliant) stored locally on the web server. Now I'm wondering what would the best method to allow searching of these RSS files. Since the search will cater to multiple users the search system has to be robust and efficient. Some ideas that I have for the RSS search system are: 1. Store all RSS...
2
1681
by: tmb | last post by:
I'm trying to use the Microsoft Search to search for a text string in a folder full of a bunch of ASP files. Seems like the normal "Search for text in files" program in XP Pro won't search between the ASP delimiters <% %> How can I search for text strings in ASP a folder full of ASP files with out opening each one individually and searching? thanks for any help.
60
49043
by: Julie | last post by:
What is the *fastest* way in .NET to search large on-disk text files (100+ MB) for a given string. The files are unindexed and unsorted, and for the purposes of my immediate requirements, can't be indexed/sorted. I don't want to load the entire file into physical memory, memory-mapped files are ok (and preferred). Speed/performance is a requirement -- the target is to locate the string in 10 seconds or less for a 100 MB file. The...
3
6545
by: Ya Ya | last post by:
I have a folder with a lot of PDF and CHM files. I would like to develope an ASP.net application that enables the user to search inside the content of those files. How do I search inside those type of files ? Thanks for your time ra294@hotmail.com
1
1526
by: Rachelle | last post by:
I'm having some trouble with the search field that i am setting up using PHP and HTML, I am connecting to a database to return proper information pertaining to something being searched. I originally set up a search to work like this : $SQL = " select id, name from repository where upper(name) like upper('%$search%')
3
9546
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and MusicAlbum let you find MP3 and other music files based on the singer and album name; DocAuthor let you find Office documents created by a certain user; DocAppName let you find files of a particular program, and so on. Indexing Service uses plug-ins...
5
2686
by: Mark | last post by:
Hi I have an application (in vb.NET 2005) which holds data in SQL Server and some of the SQL records are simply paths to related files. I would like to be able to do a text search on both the SQL data and the contents of any referenced files. The returned list being a listing which includes both records containing the text and files containing the text. Does anyone have a simple example of programatically searching for files
9
1705
by: Lloyd Sheen | last post by:
For all those who don't think that a recursive search of files in folders is a good thing in the Microsoft.VisualBasic.FileIO.FileSystem namespace listen to this. I am reorg my mp3 collection. I have written my own catalog program and it has xml files to cache info from tags etc. To ensure that the process goes ok I went to delete all the xml files to force a rescan of the tags. This should be simple ..... but this is Vista. So...
3
3543
by: =?Utf-8?B?UGVycmlud29sZg==?= | last post by:
Not sure where to post this... Found some interesting behavior in Windows Search (Start =Search =All files and folders =search for "A word or phrase in the file:"). This applies to XP and maybe other Windows flavors. Procedure: 1. Create a simple text file named test.txt. 2. Open the text file in a text editor and add a simple test word such as "blah" (not quotes).
0
10748
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
8059
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
8000
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,...
1
8145
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,...
0
8330
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6011
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
5475
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
3960
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2474
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
0
1328
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.