filenames

Accessing the real file name of a symbolic linked file

风格不统一 提交于 2019-12-23 19:22:20
问题 When a file is loaded/required via a symbolic link, all the methods, keywords, etc. that refer to a file name seem to refer to the link name, and not the real file name. For example, suppose I have a file foo.rb with its contents something like: puts __FILE__, __dir__, caller and a symbolic link bar.rb pointing to foo.rb . If I load/require foo.rb via the symbolic link bar.rb , then all of the file names given by the commands above describe the symbolic link name bar.rb , and not the real

Inverse glob - reverse engineer a wildcard string from file names

我怕爱的太早我们不能终老 提交于 2019-12-23 16:25:06
问题 I want to generate a wildcard string from a pair of file names. Kind of an inverse-glob. Example: file1 = 'some foo file.txt' file2 = 'some bar file.txt' assert 'some * file.txt' == inverse_glob(file1, file2) Use difflib perhaps? Has this been solved already? Application is a large set of data files with similar names. I want to compare each pair of file names and then present a comparison of pairs of files with "similar" names. I figure if I can do a reverse-glob on each pair, then those

Swift: How to extract image filename from an array of UIImage

╄→尐↘猪︶ㄣ 提交于 2019-12-23 15:22:38
问题 If I have an array of UIImage like so: newImageArray = [UIImage(named:"Red.png")!, UIImage(named:"Green.png")!, UIImage(named:"Blue.png")!, UIImage(named:"Yellow.png")!] How can I extract or determine the filename of an image of a certain index later on? For example: println("The first image is \(newImageArray[0])") Instead of returning a readable filename, it returns: The first image is <UIImage: 0x7fe211d2b1a0> Can I convert this output into readable text, or is there a different method of

How to safely save file to disk without the risk of windows reject it?

扶醉桌前 提交于 2019-12-23 12:42:34
问题 I'm developing a winform application. I want to take input from user (i.e. the user provides username) and use that input as part of filename and save to file. How do I check if the username provided by the user didn't contain windows' reserved characters. And what is the list of reserved characters for windows? 回答1: via: Path.GetInvalidFileNameChars() and Path.GetInvalidPathChars() The exact list could be platform-specific (especially for mono), and it includes some non-printable characters.

PHP: escape filename as linux does

前提是你 提交于 2019-12-23 12:08:12
问题 I'm having troubles with filenames upload by users which I have to process. When I try to access them, because some of them have special characters, the command used says the file is not found or similar. I've used escapeshellcmd with no sucess. When I use the "tab" key in linux console (when you have started to type the filename and you want it to complete), the bash escape the filename correctly, and if I use exactly that "escaped" filename, it works. I've tried this: preg_replace("/[^a-zA

How to handle undecodable filenames in Python?

守給你的承諾、 提交于 2019-12-23 07:32:11
问题 I'd really like to have my Python application deal exclusively with Unicode strings internally. This has been going well for me lately, but I've run into an issue with handling paths. The POSIX API for filesystems isn't Unicode, so it's possible (and actually somewhat common) for files to have "undecodable" names: filenames that aren't encoded in the filesystem's stated encoding. In Python, this manifests as a mixture of unicode and str objects being returned from os.listdir() . >>> os

how to change filename of exported SSRS report

淺唱寂寞╮ 提交于 2019-12-23 05:27:18
问题 I have created SSRS report and want to change the name of file with adding Date to it. I really appreciate your help. Already tried https://reportsyouneed.com/ssrs-adding-date-to-exported-filenames/ solution and it doesn't work. 回答1: I got a perfect solution for this Issue. This link works (very well) only if there is no parameter required before export. Code in this link try to get the file name when you click on the file, means when download not ready and report looking for initial inputs.

Talend get current filename

南笙酒味 提交于 2019-12-23 04:47:15
问题 I want to load excel files into the mysql database and check that they do not already exist, my problem is that I can not extract the name of the current file. For example, I have the following files A.xlsx , B.xlsx and C.xls . It return always B.xlsx 回答1: I think the issue you have is that your "RunIf" link is before the iterator, and therefore it's not being triggered at the right time. The image below shows a simplified version, where I list the rows in the spreadsheets and then the file

Python function to make arbitrary strings valid filenames

穿精又带淫゛_ 提交于 2019-12-22 11:04:10
问题 Is there a built-in function which strips all characters which cannot be in Windows filenames from a string or replaces them somehow? E.g. function("Some:unicode\symbols") --> "Some-unicode-symbols" 回答1: import re arbitrary_string = "File!name?.txt" cleaned_up_filename = re.sub(r'[/\\:*?"<>|]', '', arbitrary_string) filepath = os.path.join("/tmp", cleaned_up_filename) with open(filepath, 'wb') as f: # ... Taken from User gx Obviously adapt to your situation. 来源: https://stackoverflow.com

Programmatically determine maximum filename length

走远了吗. 提交于 2019-12-22 06:23:59
问题 How can I determine the maximum filename length on a linux box? Preferred in PHP programming language. 回答1: You want pathconf or fpathconf, which are not exposed (yet) in PHP. (When they are, they'll probably be posix_pathconf .) You may also shell out to getconf, a command-line utility interface to the same functionality. Try this on your system: $ getconf NAME_MAX /tmp $ getconf PATH_MAX /tmp 回答2: there's no need to programatically determine it. it's 255 bytes. edit: you can have longer