filenames

Is it the filename or the whole URL used as a key in browser caches?

删除回忆录丶 提交于 2019-11-29 03:11:49
It's common to want browsers to cache resources - JavaScript, CSS, images, etc. until there is a new version available, and then ensure that the browser fetches and caches the new version instead. One solution is to embed a version number in the resource's filename, but will placing the resources to be managed in this way in a directory with a revision number in it do the same thing? Is the whole URL to the file used as a key in the browser's cache, or is it just the filename itself and some meta-data? If my code changes from fetching /r20/example.js to /r21/example.js , can I be sure that

Get name of file that is including a PHP script

本秂侑毒 提交于 2019-11-29 03:06:00
Here is an example of what I am trying to do: index.php <ul><?php include("list.php") ?></ul> list.php <?php if (PAGE_NAME is index.php) { //Do something } else { //Do something } ?> How can I get the name of the file that is including the list.php script (PAGE_NAME)? I have tried basename(__FILE__) , but that gives me list.php . $_SERVER["PHP_SELF"]; returns what you want zerkms If you really need to know what file the current one has been included from - this is the solution: $trace = debug_backtrace(); $from_index = false; if (isset($trace[0])) { $file = basename($trace[0]['file']); if (

How do I resolve a canonical filename in Windows?

此生再无相见时 提交于 2019-11-29 03:04:49
问题 If I have a string that resolves to a file path in Windows, is there an accepted way to get a canonical form of the file name? For example, I'd like to know whether C:\stuff\things\etc\misc\whatever.txt and C:\stuff\things\etc\misc\other\..\whatever.txt actually point to the same file or not, and store the canonical form of the path in my application. Note that simple string comparisons won't work, nor will any RegEx magic. Remember that we have things like NTFS reparse points to deal with

How to get pdf filename with Python requests?

[亡魂溺海] 提交于 2019-11-29 03:00:48
I'm using the Python requests lib to get a PDF file from the web. This works fine, but I now also want the original filename. If I go to a PDF file in Firefox and click download it already has a filename defined to save the pdf. How do I get this filename? For example: import requests r = requests.get('http://www.researchgate.net/profile/M_Gotic/publication/260197848_Mater_Sci_Eng_B47_%281997%29_33/links/0c9605301e48beda0f000000.pdf') print r.headers['content-type'] # prints 'application/pdf' I checked the r.headers for anything interesting, but there's no filename in there. I was actually

File.list() retrieves file names with NON-ASCII characters incorrectly on Mac OS X when using Java 7 from Oracle

与世无争的帅哥 提交于 2019-11-29 02:23:04
问题 I have a problem using File.list() with file names with NON-ASCII characters incorrectly retrieved on Mac OS X when using Java 7 from Oracle. I am using the following example: import java.io.*; import java.util.*; public class ListFiles { public static void main(String[] args) { try { File folder = new File("."); String[] listOfFiles = folder.list(); for (int i = 0; i < listOfFiles.length; i++) { System.out.println(listOfFiles[i]); } Map<String, String> env = System.getenv(); for (String

Get filename from string-path?

浪尽此生 提交于 2019-11-29 01:42:43
问题 How do I get the filename from this string? "C:\Documents and Settings\Usuario\Escritorio\hello\test.txt" output: "test.txt" I really tried to find this one before posting, but all the results were contaminated, they talk about getting filenames from current dir (I must work with strings only) 回答1: Method 1 for %%F in ("C:\Documents and Settings\Usuario\Escritorio\hello\test.txt") do echo %%~nxF Type HELP FOR for more info. Method 2 call :sub "C:\Documents and Settings\Usuario\Escritorio

Get file name from a file location in Java

一个人想着一个人 提交于 2019-11-29 00:59:38
I have a String that provides an absolute path to a file (including the file name). I want to get just the file's name. What is the easiest way to do this? It needs to be as general as possible as I cannot know in advance what the URL will be. I can't simply create a URL object and use getFile() - all though that would have been ideal if it was possible - as it's not necessarily an http:// prefix it could be c:/ or something similar. akarnokd new File(fileName).getName(); or int idx = fileName.replaceAll("\\\\", "/").lastIndexOf("/"); return idx >= 0 ? fileName.substring(idx + 1) : fileName;

Create (sane/safe) filename from any (unsafe) string

℡╲_俬逩灬. 提交于 2019-11-28 23:36:38
问题 I want to create a sane/safe filename (i.e. somewhat readable, no "strange" characters, etc.) from some random Unicode string (mich might contain just anything). (It doesn't matter for me wether the function is Cocoa, ObjC, Python, etc.) Of course, there might be infinite many characters which might be strange. Thus, it is not really a solution to have a blacklist and to add more and more to that list over the time. I could have a whitelist. However, I don't really know how to define it. [a

File extension for a Serialized object

夙愿已清 提交于 2019-11-28 21:22:01
What file extension would be most suitable when saving a Serializable object to disk? FileOutputStream fos = null; ObjectOutputStream out = null; try { fos = new FileOutputStream(filename); out = new ObjectOutputStream(fos); out.writeObject(mySerializableObject); } catch (IOException ex) { ex.printStackTrace(); } finally { IOUtils.closeQuietly(out); } ".ser" is a reasonable choice for the file suffix - http://www.file-extensions.org/ser-file-extension However, you could argue that it make little difference what suffix you use ... provided that is doesn't clash other commonly used application

Tab-completion of filenames as arguments for MATLAB scripts

耗尽温柔 提交于 2019-11-28 21:17:08
We all know MATLAB provides tab-completion for filenames used as arguments in MATLAB function like importdata , imread . How do we do that for the functions we create? EDIT: Displays the files and folders in the current directory. Caution: unsupported hack here. Take a look at the file toolbox\local\TC.xml in your Matlab installation. This appears to contain the argument type mappings for tab completion. (I found this by just grepping the Matlab installation for "imread" in R2009b.) Adding this line inside the <TC> element will get you tab-completion of file names for each of its arguments.