filepath

Run a script in the same directory as the current script

蹲街弑〆低调 提交于 2019-11-30 05:40:21
I have two Bash scripts in the same folder (saved somewhere by the user who downloads the entire repository): script.sh is run by the user helper.sh is required and run by script.sh The two scripts should be in the same directory. I need the first script to call the second one, but there are two problems: Knowing the current working directory is useless to me, because I don't know how the user is executing the first script (could be with /usr/bin/script.sh , with ./script.sh , or it could be with ../Downloads/repo/scr/script.sh ) The script script.sh will be changing to a different directory

C# Filepath Recasing

陌路散爱 提交于 2019-11-30 04:44:28
I'm trying to write a static member function in C# or find one in the .NET Framework that will re-case a file path to what the filesystem specifies. Example: string filepath = @"C:\temp.txt"; filepath = FileUtility.RecaseFilepath(filepath); // filepath = C:\Temp.TXT // Where the real fully qualified filepath in the NTFS volume is C:\Temp.TXT I've tried the following code below and many variants of it and it still doesn't work. I know Windows is case-insensitive in general but I need to pass these file paths to ClearCase which considers file path casing since it's a Unix and Windows application

Can Greasemonkey work with the file:// protocol?

房东的猫 提交于 2019-11-30 03:39:59
问题 I have a simple Greasemonkey script: // ==UserScript== // @name hello // @namespace http://www.webmonkey.com // @description A test of accessing documents using file:// protocol // @include http* file* // @grant none // ==/UserScript== alert("hi"); It works fine as long as the URL is of the form http://... How do I also get the script to run on URLs of the form file://... ? In the User Settings section I have http://* and file://* as the included pages and in the Script Settings section I

Inno Setup Compiler “Cannot find the path specified” error with long paths

懵懂的女人 提交于 2019-11-30 03:24:13
问题 I am using a .iss script to build an exe file inside Inno Setup Compiler. I need to package some node_modules into this application so I have a line under [Files] which looks like this: Source: "{#SourcePath}Encore.Warehouse.UI\bin\Warehouse_Release\warehouse\*"; \ DestDir: "{app}\warehouse"; Flags: ignoreversion recursesubdirs createallsubdirs When I compile, I receive this error: Here is the compiler output: So, it appears to be running fine up until it aborted. My initial thought was that

Hard disk volume path to full file path

泪湿孤枕 提交于 2019-11-29 22:40:00
问题 I have an MSVC++ application that spits out the hard disk volume paths of file handles that other applications have open in the following string format: \Device\HarddiskVolume4\Users\User\Documents\Visual Studio 2013\Projects\FileLocker\FileLocker\bin\Debug\Test.txt I would like to convert these paths to full paths to these files in Windows. For example, I would like to convert the above hard disk volume path to a full Windows file path with its corresponding drive letter: C:\Users\User

Extract a part of the filepath (a directory) in Python

眉间皱痕 提交于 2019-11-29 20:32:01
I need to extract the name of the parent directory of a certain path. This is what it looks like: c:\stuff\directory_i_need\subdir\file I am modifying the content of the "file" with something that uses the directory_i_need name in it (not the path). I have created a function that will give me a list of all the files, and then... for path in file_list: #directory_name = os.path.dirname(path) # this is not what I need, that's why it is commented directories, files = path.split('\\') line_replace_add_directory = line_replace + directories # this is what I want to add in the text, with the

phpunit require_once() error

纵然是瞬间 提交于 2019-11-29 20:05:45
I recently installed phpunit on my server via the pear installer. When I go to run a test I get the following error: PHP Warning: require_once(PHPUnit/Util/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 44 PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Util/Filter.php' (include_path='.:/usr/bin/php') in /usr/bin/phpunit on line 44 After doing some searching, I tried making some modifications to the include_path in my php.ini file on the server. But that hasn't done a thing. Any idea what might be causing this? UPDATE: As of 2013

What is the preferred way to write a file path in Python

元气小坏坏 提交于 2019-11-29 17:38:51
When writing a file path in python, I have seen several variations to write the syntax and I was curious if there is just one preferred way: the examples are: myFile= r"C:\My Documents\test\hello.txt" myFile = "C:\\My Documents\\test\\hello.txt" myFile = "C:/My Documents/test/hello.txt" If someone could provide some guidance, it would greatly be appreciated. Oh, just as a for info, my skill level in writing python is novice. The 1st and 2nd are completely equivalent. The third one is the shortest in terms of the character count. Also, forward slash is supported as path separator on platforms

Convert a classpath filename to a real filename

旧巷老猫 提交于 2019-11-29 17:23:04
问题 How would I convert the name of a file on the classpath to a real filename? For example, let's say the directory "C:\workspace\project\target\classes" is on your classpath. Within that directory is a file, such as info.properties . How would you determine (at runtime) the absolute file path to the info.properties file, given only the string "info.properties" ? The result would be something like "C:\workspace\project\target\classes\info.properties" . Why is this useful? When writing unit tests

python replace backslashes to slashes

岁酱吖の 提交于 2019-11-29 13:43:56
How can I escape the backslashes in the string: 'pictures\12761_1.jpg' ? I know about raw string. How can I convert str to raw if I take 'pictures\12761_1.jpg' value from xml file for example? You can use the string .replace() method. >>> print r'pictures\12761_1.jpg'.replace("\\", "/") pictures/12761_1.jpg You can also use split/join: print "/".join(r'pictures\12761_1.jpg'.split("\\")) EDITED: The other way you may use is to prepare data during it's retrieving(e.g. the idea is to update string before assign to variable) - for example: f = open('c:\\tst.txt', "r") print f.readline().replace('\