Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 01-09-08   #1 (permalink)
Overclocker
 
ZionEx's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: Places
Posts: 408

Rep: 18 ZionEx Unknown
Unique Rep: 0
Trader Rating: 0
Default C++ Searching for a Directory

Hello, I am trying to figure out how to go about searching for a directory on my C:\ volume using C++. Any help would be appreciated.
__________________
System: Iron Man
CPU
E8400 3.6GHz
Motherboard
DFI X38-T2R
Memory
Ballistix PC2-6400
Graphics Card
EVGA 8800GT SC
Hard Drive
WD1600AAJS
Case
Antec 300
CPU cooling
Geminii 2x Antec 120mm Pro DBB
GPU cooling
Thermaltake Duo Orb
OS
XP Pro
Monitor
AL2016WBBD
ZionEx is offline   Reply With Quote
Old 01-10-08   #2 (permalink)
Programmer
 
kdbolt70's Avatar
 
intel ati

Join Date: May 2007
Location: Walled Lake, MI
Posts: 1,112

Rep: 127 kdbolt70 is acknowledged by manykdbolt70 is acknowledged by many
Unique Rep: 0
Folding Team Rank: 195
Trader Rating: 1
Default

Well, C++ isn't really the language you'd want to use for searching for files and directories. The main reason being all platforms have different ways of storing the directory tree structure. What will work in windows wont work in a unix environment. You could either run a script outside of the C++ program, or try using a platform specific library. Alternatively, you could check out Boost's Filesystem Library, seen here. While I have used Boost before, I've never used this particular library, so you'll probably want to check elsewhere (including Boost's site) for more info. Hope this helps.
__________________

~M Hail to the Victors M~

System: It's about time!
CPU
Q6600 G0 @3.3Ghz
Motherboard
Gigabyte P35-DS3L
Memory
2Gb Ballistix DDR2 800 @915Mhz
Graphics Card
Sapphire 2900Pro Flashed to XT
Hard Drive
Seagate Barracuda 320Gb
Sound Card
Onboard
Power Supply
Corsair HX 620W
Case
CM 690
CPU cooling
Tuniq Tower 120
GPU cooling
stock
OS
Vista Business and VMWare Ubuntu
Monitor
Acer AL2223W 22"
kdbolt70 is offline I fold for Overclock.net   Reply With Quote
Old 01-10-08   #3 (permalink)
Overclocker
 
ZionEx's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: Places
Posts: 408

Rep: 18 ZionEx Unknown
Unique Rep: 0
Trader Rating: 0
Default

Well this is a start. I am just trying to get familiar with C++ and my friend gave me the idea for this little program to help me. I am not really too concerned with program portability. Long as I can get it to work on Windows I am fine. I will check the site out when I get home later. Thank you.
__________________
System: Iron Man
CPU
E8400 3.6GHz
Motherboard
DFI X38-T2R
Memory
Ballistix PC2-6400
Graphics Card
EVGA 8800GT SC
Hard Drive
WD1600AAJS
Case
Antec 300
CPU cooling
Geminii 2x Antec 120mm Pro DBB
GPU cooling
Thermaltake Duo Orb
OS
XP Pro
Monitor
AL2016WBBD
ZionEx is offline   Reply With Quote
Old 01-10-08   #4 (permalink)
WaterCooler
 
intel nvidia

Join Date: Sep 2006
Location: La Quinta, CA
Posts: 676

Rep: 42 nagal is acknowledged by some
Unique Rep: 0
Trader Rating: 19
Default

Just use the Win32 API in C++.
__________________
Michael

Check out my Wolf in Sheep's clothing build log

New build log BlackBox aka Nagal's folly as it was never finished

Duct Tape Fan Shroud Representing the Ghetto Mod Community

Quote:
Originally Posted by DuckieHo View Post
Like terrorists/hackers/ninjas are sitting around waiting for the news to tell them what to do next?

System: Home built MacPro
CPU
Dual ES Clovertowns
Motherboard
MacPro
Memory
4 x 2GB FB-DIMM
Graphics Card
Nvidia 7300GT
Hard Drive
Which one?
Sound Card
Presonus FirePod
Power Supply
MacPro 980W
Case
MacPro
CPU cooling
Dual Thermal Right HR-01X
OS
OS X 10.5
Monitor
Dual ViewSonic VP201B
nagal is offline   Reply With Quote
Old 01-10-08   #5 (permalink)
Programmer
 
kdbolt70's Avatar
 
intel ati

Join Date: May 2007
Location: Walled Lake, MI
Posts: 1,112

Rep: 127 kdbolt70 is acknowledged by manykdbolt70 is acknowledged by many
Unique Rep: 0
Folding Team Rank: 195
Trader Rating: 1
Default

If you're just trying to get aquainted with C++, doing directory stuff probably isn't the best place to start, unless you have programming experience in other languages. Just an opinion though.
__________________

~M Hail to the Victors M~

System: It's about time!
CPU
Q6600 G0 @3.3Ghz
Motherboard
Gigabyte P35-DS3L
Memory
2Gb Ballistix DDR2 800 @915Mhz
Graphics Card
Sapphire 2900Pro Flashed to XT
Hard Drive
Seagate Barracuda 320Gb
Sound Card
Onboard
Power Supply
Corsair HX 620W
Case
CM 690
CPU cooling
Tuniq Tower 120
GPU cooling
stock
OS
Vista Business and VMWare Ubuntu
Monitor
Acer AL2223W 22"
kdbolt70 is offline I fold for Overclock.net   Reply With Quote
Old 01-10-08   #6 (permalink)
Overclocker
 
ZionEx's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: Places
Posts: 408

Rep: 18 ZionEx Unknown
Unique Rep: 0
Trader Rating: 0
Default

WIN32 API, not that familiar but I will see what I can find. I am just trying to figure out some basic programs I can try to make in order to better understand the abilities of C++.
__________________
System: Iron Man
CPU
E8400 3.6GHz
Motherboard
DFI X38-T2R
Memory
Ballistix PC2-6400
Graphics Card
EVGA 8800GT SC
Hard Drive
WD1600AAJS
Case
Antec 300
CPU cooling
Geminii 2x Antec 120mm Pro DBB
GPU cooling
Thermaltake Duo Orb
OS
XP Pro
Monitor
AL2016WBBD
ZionEx is offline   Reply With Quote
Old 01-13-08   #7 (permalink)
Programmer
 
intel ati

Join Date: Aug 2006
Location: Moscow, ID
Posts: 159

Rep: 10 Safetydan Unknown
Unique Rep: 0
Trader Rating: 1
Default

How much coding have you done (in C++ or other languages)? If you're pretty confident then something like...

Read in two text files with one word on each line, alphabetize all the words and write them to a new text file.

..might be a good little exercise. If that seems to advanced or basic let me know and I'll dig through old homework or whatever to find something else for you to try out.
__________________
"He attacked everything in life with a mix of extraordinary genius and naive incompetence, and it was often difficult to tell which was which."
Douglas Adams

System: Monster v2
CPU
Q6600 G0
Motherboard
GA-P35-DS3L
Memory
2GB Crucial Ballistix
Graphics Card
Saphire Radeon x1900XTX
Hard Drive
WD 320GB
Sound Card
x-fi extreme music (modded)
Power Supply
OCZ 700W
Case
Gigabyte 3D aurora
CPU cooling
TR Ultra-120 Extreme
GPU cooling
vf900
OS
Windows XP
Monitor
2x Acer 22" WS
Safetydan is offline   Reply With Quote
Old 05-21-08   #8 (permalink)
Overclocker in Training
 
intel nvidia

Join Date: Nov 2005
Posts: 195

Rep: 3 loco1172 Unknown
Unique Rep: 0
Trader Rating: 2
Default

search for CFileFind in msdn
__________________
CPU-Z Validation
GPU-Z Validation

System: slow POS (getting faster)
CPU
E6600 @ 3.5 v1.496
Motherboard
EVGA 680i A1 SLI
Memory
2 x 2gb G.Skill 1000
Graphics Card
2 x EVGA 8800 GTX SLI
Hard Drive
500gb wd, 250gb wd, 250gb maxtor
Power Supply
Antec TruePower Trio 650 Watt
Case
CM 690
CPU cooling
TRUE & yate loom D12SH-12 (lapped)
GPU cooling
Stock (better needed)
OS
Vista 64 Bit (SP1)
Monitor
Envision 20" LCD
loco1172 is offline   Reply With Quote
Old 05-23-08   #9 (permalink)
New to Overclock.net
 
Join Date: May 2008
Location: Nottingham, UK
Posts: 24

Rep: 7 Stormwolf Unknown
Unique Rep: 0
Trader Rating: 0
Default

...or use the Boost Filesystem library (the following code example is from the two-minute tutorial)

Code:
#include "boost/filesystem.hpp"   // includes all needed Boost.Filesystem declarations
#include <iostream>               // for std::cout
using boost::filesystem;          // for ease of tutorial presentation;
                                  //  a namespace alias is preferred practice in real code

bool find_file( const path & dir_path,         // in this directory,
                const std::string & file_name, // search for this name,
                path & path_found )            // placing path here if found
{
  if ( !exists( dir_path ) ) return false;
  directory_iterator end_itr; // default construction yields past-the-end
  for ( directory_iterator itr( dir_path );
        itr != end_itr;
        ++itr )
  {
    if ( is_directory(itr->status()) )
    {
      if ( find_file( itr->path(), file_name, path_found ) ) return true;
    }
    else if ( itr->leaf() == file_name ) // see below
    {
      path_found = itr->path();
      return true;
    }
  }
  return false;
}
Stormwolf is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 07:26 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.25995 seconds with 9 queries