filesyncprovider creates folders for documents with same name as document - microsoft-sync-framework

I am building a sync app with a customprovider and a filesyncprovider. I based my provider on this example:
https://code.msdn.microsoft.com/File-Sync-with-Simple-c497bf87
Now I want to extend to a hierarchical folderstructure. So in the EnumerateItems method of the custom syncprovider I return all files and folders just like I did before with only the files in the directory. Now on the filesyncprovider side, this results in a creation of folders with the name of the file and the file being placed in this folder. E.g.
Folder1\textfile.txt\textfile.txt
I have no idea, what I am doing wrong and I find it hard to know the part of the MS filesyncprovider where I could debug to see, what's happening.
My question is, what am I doing wrong and how can I correct it, so that the correct output would be
Folder1\textfile.txt?
Best regards,
Tobias

// Must return the relative path without the filename
public string RelativeDirectoryPath
{
get
{
return _relativeFilePath;
}
Read first - then ask: I returned the path to the file instead of the path to the folder... comment above even warns not to do that...

Related

CakePHP 3.x, How to get full path to a template file

I've tried $this->viewBuilder()->templatePath(), but this only returns the prefix and controller name. (ex. Dashboard/Users)
The full path is more like /usr/local/var/www/mysite/vendor/vendorname/users/src/Template/Dashboard/Users
I've tried a few other things like Plugin::path($this->viewBuilder()->plugin()) to get part of that path, but I have yet to find any piece of code that will return the settings for what the src folder is called and what the Template folder is called.
I could hard code them as 'src' . DS . 'Template', but was hoping I'd find something that would work even if those were changed through some config setting somewhere. (Ideally there would just be a viewBuilder->absoluteTemplatePath() or something like it.)
You can retrieve possible template paths via App::path().
If you want to retrieve the template path for your Users plugin, then you could do
$templatesPath = current(\Cake\Core\App::path('Template', 'Users'));
This would give you something like
/usr/local/var/www/mysite/vendor/vendorname/users/src/Template/
It should be noted that this method doesn't necessarily return only a single path, it does so for plugin templates though.
If you need the path to an actual file, then you'll have to concatenate the remaining path segments on your own.
See also
API > \Cake\Core\App::path()

QPixmap::save() returns successful, but yields no file

The docs say this should work:
bool did=pixmap.save( "hoppy.png" );
qDebug("did is: %d",did);
My logging returns 1 suggesting, as per docs, that the save was successful. However, no file appears on my drive. According to the docs, this save() should indeed save a file, so what is missing?
According to the docs, this save() should indeed save a file, so what is missing?
Nothing missing; it is simply saved to the folder of where you run the qt executable from. If it is a direct invocation, then it is beside the executable, otherwise it is beside the script or other program that calls the qt executable (sure, the other program could modify the current working directory, but let us forget about that for a bit).
If that is not what you would like to do, you better use an absolute path to the location where you wish to save it. However, if it is some common location, consider using QStandardPaths.
Another answer notes:
Nothing missing; it is simply saved to the folder of where you run the qt executable from
However my question indicated that this is actually not the case here.
Using the full path rather than a relative path or instead of using the ~ character, resolved it.

How to combine the working directory with a user specified file (w or w/o path) to get the up-dir of the file

at the moment I'm writing a kind of lib, which gets from outside the file name 'sFilename'. With it data were written to a file it will be created, data were append to an existing file with data, data were updated in an existing file with data or the data were read from an existing data.
The user of the application with my lib should get as much as possible on information about errors of file handling.
For this purpose I code a method FileExists(...) which uses _stat() to determine if a file exists or not and a method "bool checkPermission(std::string sFilename, CFile::EOpenmode iOpenmode)" which gives back a bool if the specified file (sFilename) with the iOpenmode (Read, Write, Readwrite) have the permission to be read, written or read and written.
This method works with _stat(sFilename.c_str(), &buf) too and gives the desired information of the file back in buf.
Before checking any file I want to check if the directory containing the specified file has the desired permissions and for that I want to use the checkPermission method [works with _stat()] for the directory!
Now the problem: how can I determine easyly the containing directory? If the user just give a filename "test.txt" the file will be created or read in working directory. So its easy to get the up-directory. Its the same like the working directory. (And there its simple to use checkPermission to get detailed information about the directory).
But what about when the user not only give the file name? For exaample "....\test.txt" or "dir1\dir2\test.txt". How to combine the working directory with a specific path to gain the up-directory of the file and then to check the permissions?
Phew, I hope all is clear and it was'nt too long ;-)
Rumo
I'd suggest using the Boost FileSystem library at www.boost.org. In particular, check out the path class, which has methods such as make_absolute and parent_path.
This is Windows example code GetFileNameFromHandle to show you how to get the path from a HANDLE. I think it is what you are looking for.
http://msdn.microsoft.com/en-us/library/aa366789%28v=vs.85%29.aspx
I found out that _stat() and _access() doesn't really works for the permissions of the directories. See this stackoverflow page.
With _stat() you can't use ".\" to get information about the current directory. But _access() at least can check if a directory exists as well ".\" or "..\".
In conclusion I use _access() to check the existence of a directory and _stat() to check the permissions of an existing file. If a file should be created I'll check it by doing.
And by the way ;-) I don't need to combine working directory with the user specified file because I can use the specified file alone in _access() to determine if directory exists.
Rumo

How do I give file path for code to be checked in at TFS?

I am writing a test code (I'm just a beginner) where I need to give a file name located in my local box. I need to check-in this code as well as the file in TFS, so that when other people take latest version, they get both.
//At my local box
string myFilePath= "D:\BACKUP\samplefile.extension";
For TFS check-in, I gave following path but it failed
string myFilePath= "$MyProjectServer\SomeFolder\samplefile.extension";
Now my question is:
How can I specify the file path in my Code, so that after check-in when other people in my team take the latest version, the code will point to right file location in TFS?
Here's how you can proceed:
Add a file to the root of your unit test project and set Copy to Output Directory: Copy always. For example add test.txt. Because the file is part of the project structure it will be added under source control as all the other files.
Use the [DeploymentItem] attribute in your unit test to indicate which file will be used. You also have the possibility to organize the test files into sub-folders.
[TestMethod]
[DeploymentItem("test.txt")]
public void Index()
{
// use relative path to read the file
var actual = File.ReadAllText("test.txt");
Assert.AreEqual(actual, "some content");
}
Your TFS path string myFilePath= "$MyProjectServer\SomeFolder\samplefile.extension" is in the wrong format.
The correct format for an itemspec is:
string myFilePath= "$/MyProjectServer/SomeFolder/samplefile.extension";
Note the addition of the slash after the $ and the change of backslashes to forward slashes throughout.

Magento - locate specific core files

I am familiar with theming and using template hints in the Magento back office to locate .phtml files.
What I am not really familiar with are the core files such as app/code/core/Mage/Catalog/Model
What I need to do is override a core file like I would a core phtml file by copying it to 'my theme'.
I basically want to amend some labels which appear on the order summary page of the Magento checkout process - domain.com/checkout/cart/
I followed the trail to the phtml files using template hints. Within the app/design/frontend/default/mytheme/template/checkout/cart I found the code
renderTotals(); ?>
Now I managed, by accident, to stumble upon two of the files I wanted to change:
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Grand.php
/httpdocs/app/code/local/Mage/Sales/Model/Quote/Address/Total/Shipping.php
I made local copies of these files (http://www.magentocommerce.com/wiki/how_to/how_to_create_a_local_copy_of_app_code_core_mage) to override the default labels, like I would if I was overriding a template file.
My question is, how can you locate core files which pertain to the 'stuff' you want to change, located in function calls such as renderTotals(); ?> in the phtml files?
Not being able to pinpoint stuff like I can with template hints is slowing me down, and I am struggling to find a solution as I am not up on all the vocab surrounding Magento yet.
Hope this makes sense and thanks in advance!
From the same settings page where you turn on Template Path Hints, also turn on the "Add Block Names to Hints" setting. This will show you PHP class names such as: Mage_Sales_Model_Quote_Address_Total_Grand to which you can deduce the folder path (underscores represent a subfolder, and the last piece represents the file name).
If you're getting a block such as Mage_Sales_Model_Quote_Address_Total_Default then sometimes it just takes a little common sense to see that it's pulling in other files from the same folder (such as Grand.php and Shipping.php). But there are generally only a couple files in the same folder, so this is pretty easy to see.
As Sid Vel said, a good Search Project functionality is helpful. But if you find yourself looking at Abstract.php of some class, often you need to look in a subfolder in that directory with the proper name to find the concrete implementations. But still, it gets you very close to where you need to be.
I always use Dreamweaver's site / directory search function. It will scan through all the files in the Core folder and tell you where the function is from. In your case, I would search for "renderTotals". You need to enable PHTML editing in Dreamweaver.
Most IDE's will allow this kind of search option. In Aptana you can Ctrl + Click on the function to open the file it is coming from. Magento takes ages to index itself on Aptana, due to its sheer size.