Copying HTML file also copies the related files to it stored in _files folder can it be done for other type of files? - c++

If we have a HTML file test.htm and folder with its related files like (images, style sheets etc.) in folder with name test_files or test.files then folder get copied/moved automatically as we copy/move html file.
Mechanism of above operation
So my question is, can such thing can be achieved for other types of files too?
I have a XML file and few files related to that which I want to move along with XML file. Will it be possible?
Any pointers will be helpful.

Related

How to maintain the appropriate file type (MIME) when moving a documents (pdf, xls) from one library to another

I have a workflow that I created in moving a document from one library to another library and it works fine for word documents, but when moving excel or PDF files, the file is moved, but the filetype seems to be a word file type.
I am using Create Item in creating the item in the new library. There does not seem to be a way to update the file type or mime type using this command.

Custom config file for components

I am interested in creating a config.cfc which I want to use in differenct components.
in PHP one can create a config.php file which simply return an array. and in other php files this can be included like
use config.php
Can I simple include a .cfm file in any .cfc component? of a config.cfc which simply returns a STRUCT?
I'm not sure how to answer your question because I don't fully understand what you're trying to accomplish. In one sentence you need to return an array and in another sentence you need to return a struct. If you're looking to create a config.cfc your method(s) can return either datatype (array or struct).
To answer your other question, yes you can include a .cfm file within a .cfc. I've done it in the past, although it's not best practice.
What I would suggest instead, in your config.cfc, create any needed methods then use CreateObject() in your calling .cfm or .cfc for usage.
I have seen several projects that use a .cfm file as a config file and it sets a Coldfusion struct variable with setting values. Using cfinclude will then load the file and set a config variable (usually a struct). It could just as easily set an array although I think structs would be more flexible. There is usually logic in the code to cfinclude the config.cfm file once and store the setting in the application scope.
Another option is to use a .json file that contains the same kind of thing but in JSON format. Here's an example of an open source project that does that:
https://github.com/tonyjunkes/CFFormProtect-Revamp/blob/master/cfformprotect/config.json
The controlling code reads the file and uses deserializeJSON() to convert it to a ColdFusion struct. Since it is open source you could download this project and see exactly how it is working.
Yes, you can cfinclude a .cfm from a .cfc file.

generating subdocuments with doxygen

I have a large C++ software application documented with doxygen. How can I set it up so that I can generate subdocuments for specific classes? The classes are documented with in-source commenting, their own .dox files, and images/ directory. I need to be able to generate a standalone pdf file specific to a single class.
I can use grouping to identify what will be included in that subdocument, but how do I generate output for a single group?
If you have a specific .dox file per requested output entity, then all you need to do is define in that file as input the files declaring and defining that class.
Say for example you want an output only for class MyClass which is declared in file myclass.hpp and whose implementation is in myclass.cpp, then in myclass.dox, just add this:
INPUT = ./myclass.cpp \
./myclass.hpp
Of course, you can have different paths for .cpp and .hpp. Or you can document more than one class.
Then, run doxygen on that myclass.dox file.
Also watch out for the output folder name. For the html output, the default name is html so you might want to rename it to avoid mixing up all the different outputs. For example, you might want to add in the dox file something like:
HTML_OUTPUT = html_myclass

Open symbolic link file as rb, and not the file it is pointing to. (or generating it in buffer)

How could I possible open a symbolic link and get the content of the file instead of the file it is pointing to?
By doing:
with open('/home/symlink.txt', 'rb') as f:
data=f.read()
If the symbolic link points to /foo/faa.txt, the variable data will contain the content of faa.txt. This is a big security and file problem from my server because I'm generating zip archives.
If for example, a folder contains multiple symbolic links with different names to avoid duplicating files, the zip archive will contain multiple files instead of multiple symbolic links!
I hope to be clear enough!
An extra explanation:
The point of this is to allow downloading symlinks in a django server. The way of returning files is the following one:
response = HttpResponse()
response.write(data))
return response
This means that data must contain the content that the user will download. I can not just give it a path. So what I need to do is to give it a symbolic link. The problem is that reading a symbolic link makes python read the content where it is pointing to instead of its real content. In a few words, the user downloads the real file instead of the symbolic link!
A possible solution to this would be to get the path where the symlink points to, and then generate the link in the buffer. Is this possible?
It looks like there are 2 questions here: How can you read a symlink from the filesystem, and how can you store this in a .zip file such that it will be recreated when you unzip it.
Reading a symlink
The contents of a symlink are defined here:
http://man7.org/linux/man-pages/man7/symlink.7.html
A symbolic link is a special type of file whose contents are a string that is the pathname of another file, the file to which the link refers
You can read that path by using os.readlink (https://docs.python.org/2/library/os.html#os.readlink) - this is analogous to C's readlink function.
It's also important to note that these symlinks aren't distinguished by their content or file attributes, but by the fact that the file entry on disk points to a string rather than a file object:
In other words, a symbolic link is a pointer to another name, and not to an underlying object.
This means that there isn't really a "file" you could store in the ZIP. So how do the existing zip & unzip utilities do it?
Storing a symlink in a zip file
The spec for the ZIP format is here: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
Note that section 4.5.7 (defining UNIX Extra Field) says:
The variable length data field will contain file type specific data. Currently the only values allowed are the original "linked to" file names for hard or symbolic links, and the major and minor device node numbers for character and block device nodes. [...] Link files will have the name of the original file stored.
This means that to store a symlink, all you need to do is add the UNIX extra field block to the data you are writing (these appear to live immediately after the filename is written, and you need to set the extra field length accordingly), and populate its "Variable length data field" with the path you get from readlink. The content you store for the node will be empty.
If you're using a library to generate the zip data (recommended!), it will probably have an abstraction available for that. If not, I'd suggest you put in a feature request!
Of course, most existing zip and unzip utilities follow the same definition, which is why you are able to zip and unzip symbolic links as if they were regular files.

Include a text file in a gh-pages jekyll template also available to js

I'm making a "this day in history" sort of site in gh-pages, using javascript to pull the day's entry for the front page and a collection to store all the other entries indexed by date.
The entries are text files.
I've made markdown files as stubs to pull in the text files. I don't want to replicate the text files if possible, because then any typos I would have to remember to fix in two places.
As far as I can see, there are two ways to include the text files in the template:
{% include date.txt %} which requires the txt files to be in the _includes directory, thus not generated into the site and not available to the javascript on the front page
{% include_relative date.txt %} which requires the txt file to be in the collection folder, which is also not generated unless it has a yaml header, in which case it would be difficult to extract the text from the generated html.
Is there another way I'm missing for jekyll to include plain text files without them having to be in special _folders?
I'm using github pages, so plugins are out.
I think there is no other way to include text files through liquid. It is part of the way it separates published files from the pieces that go together to make the files.
The way forward is to adapt the javascript to read the text from a raw blob from the github repository.
But using an http request to raw.githubusercontent.com gives a Cross Origin Resource Sharing error.
So next way is to make a new collection with a new layout to output the input files as they are.