I'am working on an program in C for a web connected touchscreen.
In case internet is down, my boss want me to write in a low secured file the intels about the sales, for memory when internet will be back.
For now, its on a .txt, and I'd like to set the attribute of the file in "hidden".
One of you got a function or an open flag for that case?
The OS I am using is Windows 7.
This is specific to the operation system.
When you create a file you can pass a couple of attributes describing the file.
In case of windows you have : FILE_ATTRIBUTE_HIDDEN.
If you already have a file you can call the SetFileAttributes function.Check this link from msdn :
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365535(v=vs.85).aspx.
In Windows you can use SetFileAttributes() function described here
Related
I am writing a File System Driver for Windows 7. I'm using the Dokan library. In the FindFiles function I want to set the 8.3 alternate name. I am assuming that will show up if I use dir /x but it doesn't. I have tried passing a null terminated string then changed to a blank padded (not null terminated) string as coded below. Neither one show the alternate name the dir /x.
See http://msdn.microsoft.com/en-us/library/windows/desktop/aa365740%28v=vs.85%29.aspx for a reference to cAlternateFileName in struct _WIN32_FIND_DATA.
Does anyone have any information on this?
Here is a clip from my code:
wsprintf(w_surfaceName, L"S%d-P%02x~1", pCartIDtable[count].dsmNumber, pCartIDtable[count].pltrNumber);
wp = wcschr(w_surfaceName, L'\0');
wmemset(wp, L' ', _countof(w_surfaceName) - (wp - w_surfaceName));
wmemcpy(findData.cAlternateFileName, w_surfaceName, _countof(findData.cAlternateFileName));
FillFindData(&findData, DokanFileInfo);
Either the file doesn't have an 8.3 short-name, or the field hasn't been filled in.
Some versions of Windows have short-name generation turned off by default. Some people have short-name generation turned of just to make the file system faster. Even if you have short-name generation turned on now, that doesn't retro-actively go and generate short names across your existing file system.
And the field is not filled in anyway if the request was only for "FindExInfoBasic".
Dokan does not support 8.3 short-names at this point. Progress for implementation of this feature is tracked at: https://github.com/dokan-dev/dokany/issues/301
I'm trying to remove a file in a C program, but when I use the remove() function it completely removes the file and not sending it to the trash. How can I remove a file to trash?
Thanks in advance!
On Mac OS, you should use the recycleURLs:completionHandler: method in NSWorkspace.
Almost every operating system provides an API to perform a soft delete by moving files to the trash. Unfortunately there is no unified specification on how a trash / recycling bin should work. On Windows you can use IFileOperation, macOS has the NSFileManager and on Linux and BSD you either use a tool that implements the FreeDesktop.org trash specification such as gio trash (GNOME), kioclient5 move (KDE), trash-cli or implement your own.
Another solution is using a cross-platform library that allows to move files and directories to the trash / recycling bin like libtrashcan. This simplifies development because you only use a single function call without worrying about platform specific details.
For Windows See SHFileOperation with FOF_ALLOWUNDO.
http://msdn.microsoft.com/en-us/library/bb762164.aspx
On Mac OS X, you have to call FSMoveObjectToTrashSync (or its async friend) from CoreServices.
In linux i will do...
system("mv your_file.txt /home/username/.local/share/Trash/");
If you are on Windows try this.
Open a Command Prompt (DOS windows) and type
cd \$RECYCLE.BIN
dir \a
and you will get a list of all the trashes of all the users in your computer.
In your program move the file to the proper trash.
There is an input format option to ffmpeg -- x11grab which allows one to capture specified region and output it to file/stream. I'm trying to do the same thing programmatically, but i haven't found any non-basic tutorials/reference for ffmpeg API.
I wonder, how it is possible to open x11 region with avformat_input_file or something like this. Or should i do it with XCopyArea/etc?
(Any programming language will satisfy)
There are many applications that take a screenshot. Major hint: it's open source, use the source. If you can't find the code in ffmpeg, any example application will do:
http://git.gnome.org/browse/gnome-screenshot/tree/src/screenshot-utils.c#n425
This is gnome-screenshot source code. This example uses gdk_get_default_root_window().
I am working under Linux, with two physical ethernet interfaces.
I have grouped the two interfaces to a bonding interface for backup... and it works.
I would like to know if there is any way to know, from my C user program, what is the active interface.
Thanks
Look at /sys/class/net/bond0/bonding/active_slave and read it using a program or code of your choice. (Replace path accordingly if using an interface name different from bond0.)
Another method to know it (tested on Debian) is looking at the file /proc/net/bonding/bondX. Replace bondX with the name of your interface.
i want to add some informations to a file in C under linux, can i save that information in its notes tab using C ?
Thanks a lot
I believe you want to set the attributes of a file (file properties that gets displayed when you see file properties from a GUI shell) from your C code. You may want to check out *xattr syscalls:
http://www.kernel.org/doc/man-pages/online/pages/man2/listxattr.2.html
http://www.kernel.org/doc/man-pages/online/pages/man2/getxattr.2.html
http://www.kernel.org/doc/man-pages/online/pages/man2/setxattr.2.html
Here's some info that you might be interested in:
https://superuser.com/questions/191385/saving-notes-against-a-file-on-linux