Editing Topic: RCR250 Project: RCR | RCRchive home

RCR 250: absolute __FILE__

submitted by neoneye on Sat May 01 2004 03:01:30 AM -0700

Status: pending


Abstract

Make __FILE__ an absolute path. Currently __FILE__ reflects the path which the program were invoked with. It's always easy get a relative path from an absolute one, but not the other way!

Problem

__FILE__ is vulnerable to chdir. Many people make global variables containing the expanded path, before they start doing file manipulation. Thats kludgy, however if they didn't do anything they would have a fragile program.

Proposal

Make __FILE__ robust, so that one can rely on that it always contains a absolute path.

Analysis

This will break the widespread 'if $0 == __FILE__' ideom, see [] for discussion of $0 and __FILE__. It will for sure break many other places, which assumes the old concept.

Implementation

I don't know what to write here.


Back to RCRchive.


RCR Submission page and RCRchive powered by Ruby, Apache, RuWiki (modified), and RubLog