track progress of moving to recycle bin on windows [closed] - c++

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I was planning to use IFileOperation::DeleteItems(items) and IFileOperationProgressSink::UpdateProgress(workTotal, workSoFar) to track the progress of moving files and folders to recycle bin. But this only works well when I call it on a list of files to be deleted/move to recycle bin. Then UpdateProgress() is called correctly after each file, returning gradually increasing number of deleted items. But when I try to delete one large folder containing multiple nested subfolders and thousand of files, UpdateProgress() keeps returning 0 (as the number of files done) and then suddenly it returns for example 8000 (like 8000 files in the large folder were deleted). There is no gradual progress, it just jumps from 0% to 100 %. Is this the normal behavior? Or am I doing something wrong. I would like to show the code but even the relevant snippet is terribly long.

I simply modified the sample on Windows-classic-samples and tried at least 8,000 files in the same subfile. It works for the UpdateProgress method, the process first discover all the items, then delete it in process.
This is the sample I used.

Related

How do I make PlaySound load only some parts of the song C++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a 424 mb wav file, which I want to play, but it takes a lot of time to load, and it uses 425.6 mb of ram. Way too much ram for a dos format program. I want to load only a part of the song, then when it's almost at the final, load the second part, when the second part is played, remove from ram the first part, and etc. For this I should use 50 parts.
Here is the line of code:
PlaySound("../music/main.wav", NULL, SND_FILENAME|SND_LOOP|SND_ASYNC);
I mention that I need to run this in background, while the other commands do their roles.
PlaySound is a fairly high-level function, so it's tricky to get behavior like this. In particular, you will likely experience small silent gaps between playing back the different parts. So the best solution would be to go to a lower-level API that allows more sophisticated managing of sound playback buffers. OpenAL is a good library for doing this, the modern Windows native solution is WASAPI, which unfortunately is quite complicated to use.
With PlaySound itself, first adjust your program to load the .wav file to memory and then use SND_MEMORY for playing it from memory (example).
Now, instead of loading the whole .wav file at once, you just load the header and as many soundframes as fill your buffer. You then create your own .wav header for just those loaded samples and put it all in a contiguous buffer. You basically build your own, smaller .wav file in memory. Then you call PlaySound(..., SND_MEMORY) on that buffer. Rinse and repeat for the remaining samples from the original file.
Note that you will need your own .wav file format parser for this, but the file format is not that complicated, so hopefully this should not be too much of an issue.

Statistica VB - Including an external macro [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm using Statistica 64 VB. I wrote a function "Public MyFunction()" in FileLibrary.svb (a collection of useful functions) that I want to be called by a function in FileDoStuff.svb (an analysis).
I tried to include FileLibrary.svb like this in FileDoStuff.svb:
'#Language "WWB-COM"
'#Uses "U:\TestSVB\FileLibrary.svb"
This is the result when I run Main() in FileDoStuff, and the result is the same even if I have FileLibrary open in the application.
"Script error in FileDoStuff.svb
Macro/module does not exist."
Statistica is on the E: drive. However, FileLibrary opens a spreadsheet on U: and has no problem with it. I am able to open FileLibrary from Statistica and test it.
Why would it work to open an external spreadsheet but not call an external macro? The FileLibrary is not saved within Statistica, but neither is the analysis in FileDoStuff. What am I doing wrong?
Also, what's the difference between an SVB and an SVX file?
You know what really helps, as I discovered after hours of trying everything?
Try spelling the entire path name and the entire file name correctly, including spaces, etc. And make sure the slashes go the right way, too. (In my real path/file there are spaces.)
As much as I'd like to delete this whole question, I'm leaving it here to remind us all that sometimes the answer is just that simple. Also, I want to draw more people out who are using Statistica VB because I know there will be more questions.

Low Level File Operations Handling on Linux and Windows c++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Eventhough there are similar questions like here or here, I have a question about a different case.
By using C/C++, I want to write some bytes to a file. Initially file has data. Simply, I update the content of file : I open, write and close. However, if it fails during write and if we are unable to handle the failure (for example, application crash, interrupt, electricity shutdown etc.), what is guaranteed in output file between the list below? Which situation can happen, which cannot?
File may be empty (Deleted existing values and couldn't write new ones)
File stays locked
File may contain both old values and new values (i.e. first 5 lines are new values, last 5 lines are old values)
File may contain old value.
Anything other that I don't expect?
If you can give me OS independent approaches, I would be glad
Thanks
Write the new data to a file with the same name, but with a 'tmp' extension. Flush and close the tmp file. Delete the original file. Rename the tmp file to the original file name.
On startup, scan the folder for all files. Delete all tmp files whose name part matches an existing 'source' file, (ie. system was interrupted during the tmp file write). Rename any tmp file whose name part does not match an existing source file, (the tmp file was written, the original file was deleted but the system was interrupted before the rename).
This system depends upon the atomicity of deleting the original file. If it succeeds, you get the new data, if it fails, you get the old data. You should never get bits of each.

File search progress bar [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
updating progress bar during a file search
I'm using FindFirstFile and FindNextFile recursively to search for a file by searching 20 levels deep.
How would I go about adding a progress bar? To show the progress of the search?
I want something similar to the progress bar in explorer when you search for a file.
But how would I figure out how many total files I have to search through to figure out the % completed?
If the only thing you do is searching for a file then the only thing that comes to my mind is to calculate average amount of files per directory. I guess you have much more files than directories, so while you progress through directories you divide 100% by bigger and bigger number. Of course you may see progress stalling or even goign back.
In case you do something for each of the file, I would suggest running a separate thread that would be traversing your file system while other thread would be doing stuff on each of the found file. When the traversing thread counts all the files, and maybe even their total sizes, your progress will become most accurate (of course you will have some problems on an alive file system that may be adding or removing files in the meantime.)

Turn .txt file into .pdf file on the fly? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
Improve this question
I'm we're trying to figure out if there would be a way to convert a .txt file to a .pdf file. Here's the catch. This needs to be done behind the scenes, and on the fly. Meaning, with a radio control selected, OnOK would create a .txt file. Behind the scenes, at run time, we would like for the .txt file to be converted to a .pdf file. Ideally we would like this to be done by running an executable in the background. The executable would take input "File.txt" and output "File.pdf". We're using C++ and Visual Studio 6.
Does anyone have any experience on this? Is this possible?
libHaru may do what you want. Demo.
This a2pdf tool will probably do the trick with minimal effort. Just be sure to turn off perl syntax highlighting.
http://perl.jonallen.info/projects/a2pdf
I recommend using this open source library.
Once you have the base for generating PDF documents programmatically, you would still need a method for converting the text to the PDF elements, while keeping the text flow and word wrapping. This article may help. Please pay attention to the DoText(StreamReader sr) function. It takes text and purge it into separate lines within the PDF document, keeping the rendered within the margins.
On of the simpler methods that has worked for 3 decades e.g. more than one quarter of a century is place a postscript header before the text then use ghostscript ps2pdf it is the same method as used by some commercial apps such as acrobat
at its most basic
Copy heading.ps file.txt printfile.ps
GS -sDEVICE=pdfwrite printfile.ps printfile.pdf
Master Example can be seen here
How to modify this plaintext-to-PDF-converting PostScript from 1992 to actually specify a page size?