}
+/*
+ *----------------------------------------------------------------------------
+ *
+ * DnDFileList::AddFileAttributes --
+ *
+ * Adds files attributes.
+ *
+ * Will not add attributes if the file list was created from a clipboard
+ * buffer.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+void
+DnDFileList::AddFileAttributes(const CPFileAttributes& attributes) // IN
+{
+ ASSERT(mFullPathsBinary.empty());
+
+ if (!mFullPathsBinary.empty()) {
+ return;
+ }
+
+ mAttributeList.push_back(attributes);
+}
+
+
/*
*----------------------------------------------------------------------------
*
}
+/*
+ *----------------------------------------------------------------------------
+ *
+ * DnDFileList::GetFileAttributes --
+ *
+ * Gets a vector containing file attributes.
+ *
+ * Results:
+ * File attributes.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+std::vector<CPFileAttributes>
+DnDFileList::GetFileAttributes()
+ const
+{
+ return mAttributeList;
+}
+
+
/*
*----------------------------------------------------------------------------
*
}
+/*
+ *----------------------------------------------------------------------------
+ *
+ * DnDFileList::AttributesFromCPClipboard --
+ *
+ * Loads the attribute list from a buffer, typically from CPClipboard.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+bool
+DnDFileList::AttributesFromCPClipboard(const void *buf, // IN: Source buffer
+ size_t len) // IN: Buffer length
+{
+ const CPAttributeList *alist;
+
+ ASSERT(buf);
+ ASSERT(len);
+ if (!buf || !len) {
+ return false;
+ }
+
+ alist = reinterpret_cast<const CPAttributeList *>(buf);
+
+ mAttributeList.resize(alist->attributesLen);
+ for (uint32 i = 0; i < alist->attributesLen; i++) {
+ mAttributeList[i] = alist->attributeList[i];
+ }
+
+ return true;
+}
+
+
/*
*----------------------------------------------------------------------------
*
}
+/*
+ *----------------------------------------------------------------------------
+ *
+ * DnDFileList::AttributesToCPClipboard --
+ *
+ * Serializes attributes for CPClipboard in Attributes Format.
+ *
+ * Results:
+ * false on error, true on success.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------------
+ */
+
+bool
+DnDFileList::AttributesToCPClipboard(DynBuf *out) // IN
+ const
+{
+ CPAttributeList header;
+
+ if (!out) {
+ return false;
+ }
+
+ header.attributesLen = mAttributeList.size();
+
+ DynBuf_Append(out, &header, URI_ATTRIBUTES_LIST_HEADER_SIZE);
+ if (header.attributesLen > 0) {
+ DynBuf_Append(out,
+ &mAttributeList[0],
+ header.attributesLen * sizeof(CPFileAttributes));
+ }
+
+ return true;
+}
+
+
/*
*----------------------------------------------------------------------------
*
mRelPaths.clear();
mFullPaths.clear();
mUriPaths.clear();
+ mAttributeList.clear();
mFullPathsBinary.clear();
mFileSize = 0;
}
#define URI_FILELIST_HEADER_SIZE (1* sizeof(uint64) + 1 * sizeof(uint32))
+typedef
+#include "vmware_pack_begin.h"
+struct CPFileAttributes {
+ // File, Directory, or link. See HgfsFileType.
+ uint64 fileType;
+ // Read, write, execute permissions. See File_GetFilePermissions().
+ uint64 filePermissions;
+}
+#include "vmware_pack_end.h"
+CPFileAttributes;
+
+typedef
+#include "vmware_pack_begin.h"
+struct CPAttributeList {
+ uint32 attributesLen;
+ CPFileAttributes attributeList[1];
+}
+#include "vmware_pack_end.h"
+CPAttributeList;
+
+#define URI_ATTRIBUTES_LIST_HEADER_SIZE (1* sizeof(uint32))
+
/* Types which can be stored on the clipboard. */
/*
* XXX
extern "C" {
#include "vm_basic_types.h"
+#include "dndClipboard.h"
#include "dynbuf.h"
}
void AddFileUri(const std::string uriPath);
void AddFiles(const std::vector<std::string> fullPathList,
const std::vector<std::string> relPathList);
+ void AddFileAttributes(const CPFileAttributes& attributes);
/* Copy paste/dndV2 V2 rpc */
void SetRelPathsStr(const std::string inpath);
/* UI Local clipboard */
std::vector<std::string> GetRelPaths() const;
+ std::vector<CPFileAttributes> GetFileAttributes() const;
/* CPClipboard */
bool ToCPClipboard(DynBuf *out, bool local) const;
bool ToUriClipboard(DynBuf *out) const;
+ bool AttributesToCPClipboard(DynBuf *out) const;
bool FromCPClipboard(const void *buf, size_t len);
+ bool AttributesFromCPClipboard(const void *buf, size_t len);
void Clear();
std::vector<std::string> mRelPaths;
std::vector<std::string> mFullPaths;
std::vector<std::string> mUriPaths;
+ std::vector<CPFileAttributes> mAttributeList;
std::string mFullPathsBinary;
uint64 mFileSize;
};