absolute-path

constructing absolute path with os.path.join()

自闭症网瘾萝莉.ら 提交于 2019-11-27 03:43:38
问题 I'd like to construct an absolute path in python, while at the same time staying fairly oblivious of things like path-separator. edit0: for instance there is a directory on the root of my filesystem /etc/init.d (or C:\etc\init.d on w32), and I want to construct this only from the elements etc and init.d (on w32, I probably also need a disk-ID, like C: ) In order to not having to worry about path-separators, os.join.path() is obviously the tool of choice. But it seems that this will only ever

Absolute vs. relative paths

给你一囗甜甜゛ 提交于 2019-11-27 03:40:46
If I use absolute paths, I can't move the whole directory to a new location. If I use relative paths, I can't move individual files to new locations. What's the solution here? Do you set up a config file that holds the root path and go from there? Or do you have a rule like: Never move files around? I've seen in some projects that people use dirname( FILE ). What is the point of that, I mean, why not simply leave it out since the dirname is relative anyway (depending on where the file sits)? you should use a config file that will be included in each file first line, for example your app look

How to use relative/absolute paths in css URLs?

坚强是说给别人听的谎言 提交于 2019-11-27 03:09:04
I have a production and development server. The problem is the directory structure. Development: http://dev.com/subdir/images/image.jpg http://dev.com/subdir/resources/css/style.css Production: http://live.com/images/image.jpg http://live.com/resources/css/style.css How can I have a style.css in css folder that uses on both servers the same path for the background: url property? Is there a trick I can use with relative paths? Kobi The url is relative to the location of the CSS file , so this should work for you: url('../../images/image.jpg') The relative url goes two folders back, and then to

Absolute Path of Project's folder in Java

北城以北 提交于 2019-11-27 03:05:59
问题 Lots of confusion in this topic. Several Questions have been asked. Things still seem unclear. ClassLoader, Absolute File Paths etc etc Suppose I have a project directory structure as, MyProject-- --dist --lib --src --test I have a resource say "txtfile.txt" in "lib/txt" directory. I want to access it in a system independent way. I need the absolute path of the project. So I can code the path as abspath+"/lib/Dictionary/txtfile.txt" Suppose I do this java.io.File file = new java.io.File("");

src absolute path problem

被刻印的时光 ゝ 提交于 2019-11-27 01:18:24
I have an image in C:\wamp\www\site\img and i try to display it in a page with this: <img src="C:\wamp\www\site\img\mypicture.jpg"/> but it's not working.The file is actually there and if I try to refer to it with a relative path i got the picture <img src="../img/mypicture.jpg"> where is the error?what am I missing?? thank you again guys! You should be referencing it as localhost . Like this: <img src="http:\\localhost\site\img\mypicture.jpg"/> I think because C would be seen the C drive on the client pc, it wont let you. And if it could do this, it would be a big security hole. <img src=

Relative instead of Absolute paths in Excel VBA

这一生的挚爱 提交于 2019-11-27 01:00:51
问题 I have written an Excel VBA macro which imports data from a HTML file (stored locally) before performing calculations on the data. At the moment the HTML file is referred to with an absolute path: Workbooks.Open FileName:="C:\Documents and Settings\Senior Caterer\My Documents\Endurance Calculation\TRICATEndurance Summary.html" However I want to use a relative path to refer to it as opposed to absolute (this is because I want to distribute the spreadsheet to colleagues who might not use the

Converting relative path into absolute path?

白昼怎懂夜的黑 提交于 2019-11-26 22:21:51
问题 I'm not sure if these paths are duplicates. Given the relative path, how do I determine absolute path using a shell script? Example: relative path: /x/y/../../a/b/z/../c/d absolute path: /a/b/c/d 回答1: From this source comes: #!/bin/bash # Assume parameter passed in is a relative path to a directory. # For brevity, we won't do argument type or length checking. ABS_PATH=`cd "$1"; pwd` # double quotes for paths that contain spaces etc... echo "Absolute path: $ABS_PATH" You can also do a Perl one

PHP: Require path does not work for cron job?

一世执手 提交于 2019-11-26 20:55:20
问题 I have a cron job that needs to include this file: require '../includes/common.php'; however, when it is run via the cron job (and not my local testing), the relative path does not work. the cron job runs the following file (on the live server): /home/username123/public_html/cron/mycronjob.php and here's the error: Fatal error: require(): Failed opening required '../includes/common.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username123/public_html/cron/mycronjob.php on

How to get the absolute path for a given relative path programmatically in Linux?

蹲街弑〆低调 提交于 2019-11-26 20:24:16
问题 How to get the absolute path for a given relative path programmatically in Linux? Incase of Windows we have the _fullpath() API. In other words, I mean what is analogous API to _fullpath of Windows in Linux? 回答1: As Paul mentioned, use realpath() . Please note though, that since many file systems in Linux support hard links, any given directory can have a number of different absolute paths. 回答2: Check out the realpath function. #include <stdlib.h> #include <stdio.h> #include <linux/limits.h>

Do I need to pass the full path of a file in another directory to open()?

孤人 提交于 2019-11-26 19:48:25
问题 I have a folder with ten files in it which I want to loop through. When I print out the name of the file my code works fine: import os indir = '/home/des/test' for root, dirs, filenames in os.walk(indir): for f in filenames: print(f) Which prints: 1 2 3 4 5 6 7 8 9 10 But if I try to open the file in the loop I get an IO error: import os indir = '/home/des/test' for root, dirs, filenames in os.walk(indir): for f in filenames: log = open(f, 'r') Traceback (most recent call last): File "/home