How to select a file as part of VS Code extension configuration? - configuration

As part of the configuration of my VS Code extension, the user should be able to select a text file (actually a script for gvpr). Potential selections are included in the extension, but user-provided files should be possible.
I fail to see how file selection is supported by the configuration contribution points. So how can I do this?

There is no specific type for files/folder path, unfortunately.
You should use ”type”: “string” instead, and maybe combine with “pattern”, applying some regex to validate the path structure.
Hope this helps

Related

How can I get a list of help context IDs used in a CHM help file?

I have a C++ program that calls AfxMessageBox, passing in a help file context ID. When I click Help on the resulting message box, I get a litte error box that says "Failed to launch help." I need to verify that I'm using a valid help ID. Is there a way to examine a CHM file to find out what context IDs are valid for it? Either a commercial tool or a way to write a C# or C++ or even Python program to do it.
Edit: This is an old CHM file, and I do not have the files that were used to create it. I used 7-zip to extract its contents into a folder, but I see nothing there that tells me what context IDs the file has. When the error occurs, the C++ code assigns a value of 135 to the error, and then it adds 0x30000 (196,608) to that for no reason I know. Then, when the message box gets generated, 0x30000 is subtracted and the result, 135, is passed in to AfxMessageBox() as the help ID. I've tried both 135 and 196743 (0x30000 + 135) in the AfxMessageBox() call but neither has worked. The files extracted from the help file by 7-Zip include a set of .htm file with numbers for names, but the numbers have no relation to the context IDs that I can find.
There is another execution path in my code that uses the same help file. As near as I can tell, it uses low-level functions to create a dialog box that resembles the output of AfxMessageBox(). When I force that code path use context ID 196743, I get the expected help page. Unfortunately, it's not easy to get from the code that doesn't work to the code that does.
Edit:
Your additional Edit in the question take me back many years. Not related to your original question but some links to read:
Starting with HTML Help
Adding HTML Help to Existing Dialog-Based Application
Extracting help contextID by code you must have deep knowledge of the CHM internals.
For a single value e.g. 10000 you may want to test the contextID using PowerShell or a DOS prompt. This opens the requested .chm in the Help viewer, and uses a context ID to request a URL to display.
hh.exe -mapid 10000 ms-its:CHM-example.chm
Sometimes you only have the CHM output file and nobody can locate the source files. It’s not always possible to recover all files and data you need.
Decompiling loses the alias.h and map.h files and their information for F1-Help (context sensitive help).
You may know a CHM is something like a zipped web (HTML archive) with some additional system files of metadata. Context ID's are mostly integrated by compiling a alias.h and map.h file. The purpose of the two files is to ease the coordination between developer and help author. The mapping file links an ID to the map number - typically this can be easily created by the developer and passed to the help author. Then the help author creates an alias file linking the IDs to the topic names (See: Creating Context-Sensitive Help for Applications.
I'm using FAR HTML as a toolbox full of various authoring, file and HTML utilities (Disclaimer: It is freeware now!).
Please note there is a download link (for required Microsoft HTMLHelp Workshop) because the Microsoft download links are broken.
The CHM can be opened using FAR HTML and by copy and paste you have all ID and topic information (ALIAS section). In Help File Explorer you need to open Internal Files > #IVB.

Specify a diff tool for specific file type in Mercurial/TortoiseHg

I am interested in tracking a binary file with Hg. For visual diffing, it would be beneficial to use a specific custom tool. Is it possible to tell TortoiseHg to use a specific tool, based on file extension?
Just read <TortoiseHg>/hgrc.d/MergePatterns.rc file for common pattern and ideas, add own key(s) in [diff-patterns] inside global hg-config file.
Usual diff inside THG will call you tool for predefined extension

Is it possible to generate a read-only CSV file?

for legal reason I should let the customer be able to download a CSV file but she/he should be able only to read it, not modify it.
What's a common way of handling this use case?
Some kind of signature on the file so that if it's modified you can see it's not in his original form?
I don't need a solution bound to a specific language, I would just like to know what is the best practice.
If customer will be able to download this file into his computer, than you can't stop her/him from modifying it.
However, you may easy detect changes, the easiest will be generating a cryptographic hash function for the file, i.e.:
$ sha256sum data.csv
eea8254c7500ba3de996aa8ad6af399183f04e17d4a8102fde539dbc93a90012 data.csv

Chrome extension how to append or edit a csv file on pc

I am able to find some information on how to read a csv file on a computer but is there any way I can modify one? In my chrome extension I need to add data to each row one at a time after scraping some websites. Is there any better way then read csv, store data as variable and rewrite is everytime? This becomes problematic when the file gets large. I am looking for a way to “append ” to a existing file or a work around. Any suggestions appreciated.
Update: From comment I see it is not possible to read from file system. But is there anyway to read from within the extension directory? How should I do so if the csv file is included with in the zip file of the extension? Can I access them somehow? Code snippets would be helpful.
I'm in the middle of creating something which might help you. Right now you can upload the CSV file and append a "modifier". You can adjust the code according to your requirement. Here's the repo https://github.com/amanrOnly/CSV_Modifier

Packing a file into an ELF executable

I'm currently looking for a way to add data to an already compiled ELF executable, i.e. embedding a file into the executable without recompiling it.
I could easily do that by using cat myexe mydata > myexe_with_mydata, but I couldn't access the data from the executable because I don't know the size of the original executable.
Does anyone have an idea of how I could implement this ? I thought of adding a section to the executable or using a special marker (0xBADBEEFC0FFEE for example) to detect the beginning of the data in the executable, but I do not know if there is a more beautiful way to do it.
Thanks in advance.
You could add the file to the elf file as a special section with objcopy(1):
objcopy --add-section sname=file oldelf newelf
will add the file to oldelf and write the results to newelf (oldelf won't be modified)
You can then use libbfd to read the elf file and extract the section by name, or just roll your own code that reads the section table and finds you section. Make sure to use a section name that doesn't collide with anything the system is expecting -- as long as your name doesn't start with a ., you should be fine.
I've created a small library called elfdataembed which provides a simple interface for extracting/referencing sections embedded using objcopy. This allows you to pass the offset/size to another tool, or reference it directly from the runtime using file descriptors. Hopefully this will help someone in the future.
It's worth mentioning this approach is more efficient than compiling to a symbol, as it allows external tools to reference the data without needing to be extracted, and it also doesn't require the entire binary to be loaded into memory in order to extract/reference it.