By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,814 Members | 2,162 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,814 IT Pros & Developers. It's quick & easy.

How to find the root of a CD in Linux

P: n/a
I am creating a CD-ROM based website template. Things work fine under
Windows but when I try to run the site under Linux the path is messed
up. Therefore my JavaScript functions misinterpret the root to be the
root of the filesystem instead of the root of the cd. Any cd I make
will need to run on Windows and Linux systems and the filesystems and
the way the cd's are mounted are always different. For example:

Windows root path for a cd:
-- D:\
-- /

Linux root path 1 for a cd:
-- file:///media/cdrom/index.html
-- /media/cdrom

Linux root path 2 for a cd:
-- file:///dev/cdrom/index.html
-- /dev/cdrom

This would make an absolute link like this:

/images/logo.gif

The only solution that I have been able to come up with is to use a
variable on every page that puts a prefix like this "../../" in front
of any link.

My question: Does anyone know of a way to determine the root path of
a CD that would make what I am trying to do work?

Thank you,
Jonathan Duncan
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
VK
And how about Macintosh users with ":"?

Use navigator.userAgent.indexOf() check ("Windows", "Unix", "Mac") to
set system path separator accordingly instead of hardcoded paths.
Jul 20 '05 #2

P: n/a

"Jonathan" <go**********@nacnud.com> wrote in message
news:20*************************@posting.google.co m...
I am creating a CD-ROM based website template. Things work fine under
Windows but when I try to run the site under Linux the path is messed
up. Therefore my JavaScript functions misinterpret the root to be the
root of the filesystem instead of the root of the cd. Any cd I make
will need to run on Windows and Linux systems and the filesystems and
the way the cd's are mounted are always different. For example:

Windows root path for a cd:
-- D:\
-- /

Linux root path 1 for a cd:
-- file:///media/cdrom/index.html
-- /media/cdrom

Linux root path 2 for a cd:
-- file:///dev/cdrom/index.html
-- /dev/cdrom

This would make an absolute link like this:

/images/logo.gif

The only solution that I have been able to come up with is to use a
variable on every page that puts a prefix like this "../../" in front
of any link.

My question: Does anyone know of a way to determine the root path of
a CD that would make what I am trying to do work?

Thank you,
Jonathan Duncan


There are way too many variables. In Linux, my CD can be in
/mnt/diskDrives/scsiDrives/CDdrives/drive0 if I want it to be... For that
matter, there may be more than one CD drive. Also, the CD drive in Windows
is not always the D drive. I can make my CD drove the Z drive, if I prefer.
Or, D:\ might be the CD drive, but so is F:\, due to multiple drives, so
which one is it in?

My point is that you should not be using absolute paths. Whenever possible,
use relative paths in HTML code. It makes your code much more portable...

For instance, let's say that the bulk of your information is in the /bulk
directory. In the future, you might want to add more to the CD, and the
directory will change to /HTML/bulk. If you make things relative, this will
be no problem. If you make it absolute, the entire site breaks. Relative
paths also allow you to move it to any place on a web server, and it will
continue to work.

In my experience, ../../file is much better than finding the root of a site,
and then accessing the file.

Brian
Jul 20 '05 #3

P: n/a
"VK" <sc**********@yahoo.com> wrote in message news:<3f***********************@news.freenet.de>.. .
And how about Macintosh users with ":"?

Use navigator.userAgent.indexOf() check ("Windows", "Unix", "Mac") to
set system path separator accordingly instead of hardcoded paths.


Yes that is all fine and good, but how do I get my JavaScript to
recognize where the system path ends and the CD path begins?

Jonathan
Jul 20 '05 #4

P: n/a

"Jonathan" <go**********@nacnud.com> wrote in message
news:20**************************@posting.google.c om...
"VK" <sc**********@yahoo.com> wrote in message

news:<3f***********************@news.freenet.de>.. .
And how about Macintosh users with ":"?

Use navigator.userAgent.indexOf() check ("Windows", "Unix", "Mac") to
set system path separator accordingly instead of hardcoded paths.


Yes that is all fine and good, but how do I get my JavaScript to
recognize where the system path ends and the CD path begins?

Jonathan


There is no good way of doing it, without using relative paths. Here is a
scenario in Linux:

mkdir /blah/junk/mydrive
mount /dev/hdc /blah/junk/mydrive
cd /blah/junk/mydrive
mozilla yourfile.html

At this point, the OS has no clue that there is a CD drive attached to the
file system. It knows that an IDE drive has been mounted, but that is
all... As far as Linux (or any other *nix flavor) knows, there are lots of
IDE partitions attached to the file system.

Since Linux does not know where the CD drive is, there is no way for
Javascript to do it either, since the language gets _everything_ it needs
from the host OS.

One thing you can do, is when the first page is loaded, get the path of the
URL (location.pathname, probably... get it from the window.location object).
This tells where the page was executed from, and is likely the CD, though it
can be a copy of the CD on the hard drive. Anyways, you take the value from
location.pathname and make a cookie with it. That cookie will be there for
any page in the future to read and get the value of...

Of course, the browser needs to support for cookies and the user needs to
enable them...

You can also pass the data as a field, like
nextpage.html?root_path=/blah/junk/mydrive, and in the nextpage.html, parse
the value from location.search.
But, this is ugly.

I suggest relative paths.
B
Jul 20 '05 #5

P: n/a
Thanks Brian. I understand everything you said. I was just hoping
for a silver bullet. I didn't, however, think of using cookies, that
might do the trick. Still I think you are correct with the relative
paths. I was hoping to avoid it, but it looks like that is probably
the best option.

Thanks again,
Jonathan Duncan
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.