473,672 Members | 2,696 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding a directory using a partial path name

Hi, while making an XML parser for the creation of an entire directory
list I got this problem and I'm having trouble solving it. The program
(not yet written) goes through an XML Schema Instance to create some
directories (about 5000).

While creating the directories the XML file that I'm parsing is
alphabetically ordered not hierarchically and I can't allow the program
to stock the path names for each brach on the directory tree.

The XML file looks something like this :

<Object>
<term>America </term>
<topTerm>Contin ents</topTerm>
<broaderTerm>Co ntinents</broaderTerm>
<narrowerTerm>U SA</narrowerTerm>
<narrowerTerm>M exico</narrowerTerm>
</Object>
<Object>
<term>Colorad o</term>
<topTerm>Contin ents</topTerm>
<broaderTerm>US A</broaderTerm>
<narrowerTerm>D enver</narrowerTerm>
</Object>
<Object>
<term>Continent s</term>
<narrowerTerm>A merica</narrowerTerm>
<narrowerTerm>E urope</narrowerTerm>
</Object>
<Object>
<term>Denver</term>
<topTerm>Contin ents</topTerm>
<broaderTerm>Co lorado</broaderTerm>
</Object>
<Object>
<term>USA</term>
<topTerm>Contin ents</topTerm>
<broaderTerm>Am erica</broaderTerm>
<narrowerTerm>C olorado</narrowerTerm>
<narrowerTerm>D etroit</narrowerTerm>
<narrowerTerm>L os Angeles</narrowerTerm>
</Object>

The topTerm is the root of my directory tree, each term can have a
generic node (parent) and a specific node (child) without any limits of
depth. On the example we have :

Contients->America->USA->Colorado->Denver

This is the algorith we came with for creating the directory tree :

Get list of objects
Go to first object
While there are any objects
If topTerm != NULL
If directory "topTerm" exists
If directory "broaderTer m" exists somewhere in "topTerm"
directory
Create directory "term" in "broaderTer m"
Destroy object
End If
Else
Create directory "topTerm"
End If
Else
If directory "term" doesn't exist // If you are here term is
the root of the tree
Create directory "term"
End If
End If
Go to next object
End While

As you can see whenever I try to create a new directory I just have
partial path name,I can't use the usual mkdir POSIX function and this
for every directory exept the root. If somebody knows of a fonction
that allows to find a directory using a partial path name I could use
it to create the directory tree, if not I may change the algorith for
something less practical unless you got a better idea.

Tanks.

Dec 5 '05 #1
6 1976
Sigmathaar wrote:
Hi, while making an XML parser for the creation of an entire directory
list I got this problem and I'm having trouble solving it. The program
(not yet written) goes through an XML Schema Instance to create some
directories (about 5000). [snip]

All this is off-topic here. See the FAQ for what is on-topic:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
As you can see whenever I try to create a new directory I just have
partial path name,I can't use the usual mkdir POSIX function and this
for every directory exept the root. If somebody knows of a fonction
that allows to find a directory using a partial path name I could use
it to create the directory tree, if not I may change the algorith for
something less practical unless you got a better idea.


You might look into Boost's filesystem library
(http://boost.org/libs/filesystem/doc/index.htm). Not sure if it will
do what you want, as I didn't wade through your post in detail.

Cheers! --M

Dec 5 '05 #2
mlimber wroter :
All this is off-topic here.


I don't get you, why is my post off topic? The question is about C++
not XML, my problem basically is that I can't use the POSIX mkdif
function since I don't know the entire path name of the directory I
want to create.

Can you explain me why do you think my post is off topic?

Dec 5 '05 #3
mlomber wrote :
All this is off-topic here. See the FAQ for what is on-topic:


I don't get you, why is my post of topic? I've read the FAQ and I don't
really see any problem in my topic. The question is not about XML, it's
about C++, I'm trying to create a directory without knowing his entire
name. I have someting like this :

root/.../something/mydir

My problem is that since I don't know what is in the "..." I can not
use the POSIX mkdir function. Can you please explain me why do you
think my post is of topic so I can't go somewhere else to get help with
my problem??

Dec 5 '05 #4
Sigmathaar wrote:
mlomber wrote :
All this is off-topic here. See the FAQ for what is on-topic:
I don't get you, why is my post of topic? I've read the FAQ and I don't
really see any problem in my topic.

From the cited FAQ: "[Y]our question must be answerable by looking into the C++ language definition as determined by the ISO/ANSI C++ Standard
document, and by planned extensions and adjustments."
The question is not about XML, it's about C++,
Actually, it's about doing something that the standard C++ language
doesn't innately support, so it's *not* about C++ proper, which is the
sole topic of this newsgroup. (Of course there is some leeway, but
algorithms like the one you posted are generally also outside the scope
of this group.)
I'm trying to create a directory without knowing his entire
name. I have someting like this :

root/.../something/mydir

My problem is that since I don't know what is in the "..." I can not
use the POSIX mkdir function. Can you please explain me why do you
think my post is of topic so I can't go somewhere else to get help with
my problem??


This is a much simpler description of the problem, and it is probably
what you should have posted in the first place. You could always add
detail if it is needed. However, it is still off-topic in this C++
*language* forum, but here's a brief answer:

You can't access a file or directory by absolute pathname if you don't
know the whole path. It's simply non-sensical to try. You might
consider using relative pathnames instead by changing to (or storing)
each subdirectory as it comes up.

Try comp.programmin g or an OS-specific newsgroup if that doesn't
suffice.

Cheers! --M

Dec 5 '05 #5
Thanks for the answer, I guess it is off topic, I'll try to find some
help somewhere else.

Dec 5 '05 #6
Sigmathaar wrote:
mlimber wroter :
All this is off-topic here.


I don't get you, why is my post off topic? The question is about C++
not XML, my problem basically is that I can't use the POSIX mkdif
function since I don't know the entire path name of the directory I
want to create.

Can you explain me why do you think my post is off topic?


POSIX extensions are off-topic.

This group is for C++ language issues. Unfortunately external libraries
are not topical. Boost is an oft mentioned library here, but it's
specifics are also off-topic.

HTH

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Dec 5 '05 #7

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

Similar topics

4
12364
by: Hal Vaughan | last post by:
I want to have a config file for my program, which means I need to know where the config file is. If I type: java myclass and it runs myclass.class, is there any way to obtain the location of the file myclass.class? Will this work if it's run from a relative path, like: java ../progs/myclass
11
2377
by: Fuzzyman | last post by:
What's the best, cross platform, way of finding out the directory a script is run from ? I've googled a bit, but can't get a clear answer. On sys.argv the docs say : argv is the script name (it is operating system dependent whether this is a full pathname or not). So this doesn't seem to be the answer.
1
4095
by: Bruce | last post by:
I am writing an installer that needs to put a dll file with a bunch of extended stored procedures in the BINN directory. The problem is that if the machine is running multiple instances of SQL Server, there is more than one BINN directory. The installer has a dynamically populated dropdown with the name of the instances, so does anyone know if this logic is correct and/or reliable assuming SQL Server 2000? If the instance name =...
8
2048
by: Mr. B | last post by:
I'm writing an app where I'm trying to look for and List all specific file 'types' found. So I point to a specific start top level Folder... and I want to drill down through ALL sub folders to find file types (using File Extenion). All found DWG files are listed in "lbDwgList" Listbox. I can get the top level and the 'immediate' level below the top level... but I can't figure out how to keep going down X levels (ie: All sub-levels). ...
22
2671
by: Tony Houghton | last post by:
I'm using pygame to write a game called Bombz which needs to save some data in a directory associated with it. In Unix/Linux I'd probably use "~/.bombz", in Windows something like "C:\Documents And Settings\<user>\Applicacation Data\Bombz". There are plenty of messages in the archives for this group about how to find the correct location in Windows, but what about Mac OS? There I don't know the correct location for this sort of thing at...
8
2584
by: James Owens | last post by:
I'm a relative newbie, interested in storing the information from several server directories and subdirectories in XML so that I can present it selectively using XSL (all files updated today or last MOnday, files from several drirectories in alphabetical order, things like that). To represent directories and subidrectories, is it advisable to nest the same element: <directory> <directory>
8
2012
by: Rick Strahl [MVP] | last post by:
Hi all, I'm building an app that uses the ASP.Net runtime... One problem I've run into is that pages running inside of the runtime are not finding DLLs in the GAC. In fact, if I look at the debug trace of the search path it searches the bin directory and Temporary ASP files but not the GAC. A simple example I used was trying to load System.Windows.Forms. If I add a
4
5423
by: m | last post by:
Hello I need to find out full URL of my application name, I tried using Request.ServerVariables but it returns only serverername, and I need virtual directory name as well. Thnx in advance
8
4698
by: Joshua J. Kugler | last post by:
So, I have: ModTest __init__.py AModule.py BModule.py CModule.py All works fine. However, when I import ModTest, I would like it to discover and store the names of the modules beneath it, and construct a list, say
0
8504
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
8847
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8643
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
7476
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5720
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
4439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2840
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
2
2094
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1839
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.