Can I run SourceLink manually on existing PDB files? - sourcelink

Suppose I have built a (C++ or .NET) library from source, so I have source code and PDB files locally, but I don't want to modify the library code to e.g. add /SOURCELINK or a nuget package.
Is it possible to run sourcelink on the command-line to link those existing PDBs to the git repository?

If you have not modified the source code, then yes, kind of, but you must manually download the .PDB files and include them in your compiled output folder, and upload it to git with the proper .json file conforming to the following schema:
The JSON configuration file contains a simple mapping of local file
path to URL where the source file can be retrieved via http or https.
A debugger would retrieve the original file path of the current
location from the PDB, look this path up in the Source Link map, and
use the resulting URL to download the source file.
The schema of the json file is:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "SourceLink",
"description": "A mapping of source file paths to URLs",
"type": "object",
"properties": {
"documents": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"type": "string"
},
"description": "Each document is defined by a file path and a URL. Original source file paths are compared
case-insensitively to documents and the resulting URL is used to download source. The document
may contain an asterisk to represent a wildcard in order to match anything in the asterisk's
location. The rules for the asterisk are as follows:
1. The only acceptable wildcard is one and only one '*', which if present will be replaced by a relative path.
2. If the file path does not contain a *, the URL cannot contain a * and if the file path contains a * the URL must contain a *.
3. If the file path contains a *, it must be the final character.
4. If the URL contains a *, it may be anywhere in the URL."
}
},
"required": ["documents"]
}
Unfortunately, I have not found a command line utility for creating these files beyond the disallowed /SOURCELINK in the original post.

Related

Apache Camel doneFileName with changing name

I'm currently creating some route and for one of them I have a problem.
Usually I have a data file and then a done file which have the same name prefixed by "ACK" and this works perfectly with camel and the doneFileName option.
But for one of my route I have to work with a different situation, I still receive two files but they have the same typology, it's like: MyFILE-{{timestamp}}. The data file contains the data, and the done file contains just "done".
So I need something to check the content of the file, and if it's juste "done" then process the other file.
Is there a way to handle this with camel?
The most pragmatic solution I see is to write an "adapter script" (bash or whatever you have at your disposal) that peeks into every file with a timestamp in its name.
If the file content is "done":
Lookup the other "MyFILE-{{timestamp}}" (the data file) and rename it to "MyFILE"
Rename the done file to "MyFILE.done"
Camel can then import the data file using the standard done-file-option. Because both files are renamed to something without a timestamp, the peek-script ignores them after renaming.

jMimeMagic returning mime type for docx, pptx, jar files as application/zip

I read the mimetype for .docx file is application/vnd.openxmlformats-officedocument.wordprocessingml.document. But when I upload a .docx file(one that I just created, not from a zip file) and check for its mimetype in my application using
String mimeType = Magic.getMagicMatch(file1, false).getMimeType();
I get Mimetype as application/zip.
I get the same result when I try to upload a .jar file.
I mean this way, how can I check if the user is uploading a msword or a jar file to my application?
All of the .*x Office variants (.docx, .pptx, and so on) are XML-based content which is wrapped in a ZIP "container" to keep them compact, and your library is detecting the ZIP header correctly but then either not checking for, or failing to find, the additional information that would allow it to distinguish those from a ZIP file containing whatever random data someone put into it.
Similarly, the JAR file format is an extension of the ZIP file format, so if the library does not know to check for the "special type of ZIP" case, it would simply report it as a ZIP file.

How to get the relative path segment for Apache Camel File2

I'm trying to build a file based integration where files are dumped in one of the subdirectories of a main directory for processing. I need to get the name of the sub-directory to know which client the file is for. So if I have:
/uploads/foo/bar.txt
I need to process that file and know that it's for client "foo". I'm not sure how to get that part and set it as a header for the processor that processes the bar.txt file. I've got it picking up files and processing, now I need to add in this piece.
Anyone have ideas for me?
You can get most of this information in the header of the exchange. In your situation as you are consuming the file the following items are avlable:
CamelFileName: Name of the consumed file as a relative file path with
offset from the starting directory configured on the endpoint.
CamelFileNameOnly: Only the file name (the name with no leading
paths).
CamelFileAbsolute: A boolean option specifying whether the consumed
file denotes an absolute path or not. Should normally be false for
relative paths. Absolute paths should normally not be used but we
added to the move option to allow moving files to absolute paths. But
can be used elsewhere as well.
CamelFileAbsolutePath: The absolute path to the file. For relative
files this path holds the relative path instead.
CamelFilePath: The file path. For relative files this is the starting directory + the relative filename. For absolute files this is the absolute path.
CamelFileRelativePath: The relative path.
CamelFileParent: The parent path.
CamelFileLength: A long value containing the file size.
CamelFileLastModified: A Date value containing the last modified
timestamp of the file.
You can query these headers for the information you are looking for using the following example as guidelines:
<log message ="${header.CamelFileAbsolutePath}"/>
See the file component documents at the Camel website for more details.

What is file name extension .done?

What is the file name extension ".done"?
How to handle the files with this extension? For example filename.log.gz.done is file name, can we just remove the done extension and use it?
What is the use of this file extension?
".done" is just a marker that signifies that the file is ready for consumption.
So yes, get rid of the done extension and use it.
More details can be found here: http://www.davsclaus.com/2010/12/camel-26-using-done-files-with-fileftp.html
The ".done" file extension may be appended onto any type of file, such as a .TXT or .LOG file, and may be found on an FTP server where multiple have access to the file. The DONE file helps prevents a user from accessing a file that is not meant to be accessed. The ".done" extension should be removed in order to open the actual file.
This takes you to the source from which I'm quoting my answer from. You will see a clear explanation of .done file extension and it's also a great reference for any other file extensions that you might need information about

What's the content type of a .ini file?

I'd like to make a dynamically generated .ini file available for download, is there a standardized value for the Content-Type of .ini files?
I've found some places saying it's text/plain, but I'm a bit dubious.
Checking with the IANA list of MIME Media Types shows us that .ini is not listed in the list of media types (and in particular, in the list of Text Media Types.)
Additionally, the Wikipedia entry on .ini files explains that .ini files are really just "simple text files."
One way to verify these findings is to run the following command on a given .ini file (in *nix, at least):
$ file --mime-type php.ini.default
which gives us the following result:
php.ini.default: text/plain

Resources