path

Cross-platform paths in CMake

瘦欲@ 提交于 2019-12-12 11:19:38
问题 I have a project I can build on both Linux and Windows using CMake. The only issue is that Unix-style paths, in CMakeLists.txt, can't work on Windows (which uses backslashes instead of slashes, also requiring the drive letter). Is there any way I can write a cross-platform CMakeLists.txt? 回答1: You question affects different details: Just don't use backslashes. Windows will also process slashes. Don't use drive letters. Use relative paths everywhere. GET_FILENAME_COMPONENT(X "${CMAKE_CURRENT

How to get the file URL from absolute path in Delphi?

主宰稳场 提交于 2019-12-12 11:14:18
问题 I'm looking for a Delphi function which returns the file URL path from the Windows path. Is there something for it built-in in Delphi ? Example: Input C:\Users\Documents\File.txt Output file:///C:/Users/Documents/File.txt Thanks 回答1: You can use the UrlCreateFromPath API function. Here is the example: uses ComObj, WinInet, ShLwApi; function FilePathToURL(const FilePath: string): string; var BufferLen: DWORD; begin BufferLen := INTERNET_MAX_URL_LENGTH; SetLength(Result, BufferLen); OleCheck

Maximum Possible File Name Length in Windows Kernel

谁说我不能喝 提交于 2019-12-12 11:13:00
问题 I was wondering, what is the longest possible name length allowed by the Windows kernel? E.g.: I know the kernel uses UNICODE_STRING structures to hold all object paths, and since the byte length of a wide-character string is stored inside a USHORT , that allows for a maximum path length of 2^15 - 1 characters. Is there a similar, hard restriction on a file name (rather than path)? (I don't care if NTFS or FAT32 imposes a particular restriction; I'm looking for the longest possible

windows shortcut with relative path to the icon

↘锁芯ラ 提交于 2019-12-12 11:11:13
问题 Is there a way to set relative path to the icon in win shortcut? for the target location it works fine: %windir%\system32\cmd.exe /c "cd %CD% && start fileToExecute.bat" I read that win shortcuts can pick up icon from .exe files automatically but what to do if my target file is a batch file? 回答1: It's not entirely clear what you're asking, since your title says one thing but your question says another. if the question is whether it is possible to set a relative path for the icon location in a

How do I run “dot” as a command from Python?

耗尽温柔 提交于 2019-12-12 11:05:01
问题 I am using Python on Mac OSX Leopard. I am trying to run the program 'dot' (part of Graphviz) from Python: # -*- coding: utf-8 -*- import os print os.environ['PATH'] print os.system("ls >> a.txt") print os.system("dot -o9.png -Tpng ./6.dot") The command "ls" is there just to make sure that python is in the correct directory. It is. The result that I get is: /usr/bin:/bin:/usr/sbin:/sbin 0 32512 My understanding is that 32512 error means that python could not find the file, and since the file

Path to current file depends on how I execute the program

让人想犯罪 __ 提交于 2019-12-12 11:01:10
问题 This is my Python program: #!/usr/bin/env python import os BASE_PATH = os.path.dirname(__file__) print BASE_PATH If I run this using python myfile.py it prints an empty string. If I run it using myfile.py , it prints the correct path. Why is this? I'm using Windows Vista and Python 2.6.2. 回答1: It's just a harmless windows quirk; you can compensate by using os.path.abspath(__file__) , see the docs 回答2: os.path.normpath(os.path.join(os.getcwd(),os.path.dirname(__file__))) 回答3: In many cases it

How do I specify the PATH in NetBeans?

喜夏-厌秋 提交于 2019-12-12 10:50:23
问题 When running Ruby code on NetBeans (like when running the tests) I'm having some failures because a program is not being found. That program is installed somewhere in /opt and while for the shell I get that added to my PATH, it seems NetBeans is not getting it. How do I specify the PATH in NetBeans? 回答1: In Unix, in your netbeans install directory (we'll call it $NETBEANS), there's an etc directory. $NETBEANS/etc/netbeans.conf can be changed to add things to your PATH or set other environment

Removing drive (or network name) from path in C#

天大地大妈咪最大 提交于 2019-12-12 10:29:30
问题 What's the most concise (but safe) way to remove a drive name, network path, etc. from an absolute path in C#? For example, converting \\networkmachine\foo\bar or C:\foo\bar to \foo\bar . There seem to be a good number of questions already answered with regards to path matters, but I couldn't quite find what I was looking for. My own first thought that came to mind was to use Path.GetFullPath() to ensure I'm indeed working with an absolute path and then to just use a regular expression to

Applescript Finder path into POSIX path

泪湿孤枕 提交于 2019-12-12 10:17:09
问题 I'm running the following applescript: tell application "Finder" set input to POSIX file "/Users/sam/Desktop/Resized" set theFiles to (every file of folder input whose name does not contain "- Resized") end tell return theFiles It's working as it should, though it's returning: {document file "HighResCat.jpg" of folder "Resized" of folder "Desktop" of folder "sam" of folder "Users" of startup disk of application "Finder", document file "madonna.jpg" of folder "Resized" of folder "Desktop" of

Get path that file explorer is displaying using its window handle

旧街凉风 提交于 2019-12-12 10:11:03
问题 I've succesfully obtained the handle to the current File Explorer window using 'Get handle to active window Dim hWnd As IntPtr = GetForegroundWindow() I have not been succesful finding the object that contains the path the aforementioned window is displaying. This path is supposed to reside in the process of the window, obtained too by Dim ProcessID As UInt32 = Nothing Dim ptr As UInt32 = GetWindowThreadProcessId(hWnd, ProcessID) Dim Proc As Process = Process.GetProcessById(ProcessID) However