summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/api/pp_errors.idl2
-rw-r--r--ppapi/c/pp_errors.h4
-rw-r--r--ppapi/shared_impl/file_type_conversion.cc2
-rw-r--r--ppapi/tests/test_file_io.cc38
-rw-r--r--ppapi/tests/test_file_io.h1
5 files changed, 46 insertions, 1 deletions
diff --git a/ppapi/api/pp_errors.idl b/ppapi/api/pp_errors.idl
index fc0ff4a..54a3ace 100644
--- a/ppapi/api/pp_errors.idl
+++ b/ppapi/api/pp_errors.idl
@@ -103,6 +103,8 @@
* unexpectedly.
*/
PP_ERROR_FILECHANGED = -23,
+ /** This value indicates that the pathname does not reference a file. */
+ PP_ERROR_NOTAFILE = -24,
/** This value indicates failure due to a time limit being exceeded. */
PP_ERROR_TIMEDOUT = -30,
/**
diff --git a/ppapi/c/pp_errors.h b/ppapi/c/pp_errors.h
index b02ee1b..180ebb3 100644
--- a/ppapi/c/pp_errors.h
+++ b/ppapi/c/pp_errors.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From pp_errors.idl modified Tue Mar 13 17:32:37 2012. */
+/* From pp_errors.idl modified Thu Dec 20 14:28:44 2012. */
#ifndef PPAPI_C_PP_ERRORS_H_
#define PPAPI_C_PP_ERRORS_H_
@@ -103,6 +103,8 @@ enum {
* unexpectedly.
*/
PP_ERROR_FILECHANGED = -23,
+ /** This value indicates that the pathname does not reference a file. */
+ PP_ERROR_NOTAFILE = -24,
/** This value indicates failure due to a time limit being exceeded. */
PP_ERROR_TIMEDOUT = -30,
/**
diff --git a/ppapi/shared_impl/file_type_conversion.cc b/ppapi/shared_impl/file_type_conversion.cc
index a9bd435..5185daa 100644
--- a/ppapi/shared_impl/file_type_conversion.cc
+++ b/ppapi/shared_impl/file_type_conversion.cc
@@ -26,6 +26,8 @@ int PlatformFileErrorToPepperError(base::PlatformFileError error_code) {
return PP_ERROR_NOSPACE;
case base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY:
return PP_ERROR_FAILED;
+ case base::PLATFORM_FILE_ERROR_NOT_A_FILE:
+ return PP_ERROR_NOTAFILE;
default:
return PP_ERROR_FAILED;
}
diff --git a/ppapi/tests/test_file_io.cc b/ppapi/tests/test_file_io.cc
index 9f88f00..e85bd55 100644
--- a/ppapi/tests/test_file_io.cc
+++ b/ppapi/tests/test_file_io.cc
@@ -137,6 +137,7 @@ bool TestFileIO::Init() {
void TestFileIO::RunTests(const std::string& filter) {
RUN_TEST_FORCEASYNC_AND_NOT(Open, filter);
+ RUN_TEST_FORCEASYNC_AND_NOT(OpenDirectory, filter);
RUN_TEST_FORCEASYNC_AND_NOT(ReadWriteSetLength, filter);
RUN_TEST_FORCEASYNC_AND_NOT(ReadToArrayWriteSetLength, filter);
RUN_TEST_FORCEASYNC_AND_NOT(TouchQuery, filter);
@@ -249,6 +250,43 @@ std::string TestFileIO::TestOpen() {
PASS();
}
+std::string TestFileIO::TestOpenDirectory() {
+ TestCompletionCallback callback(instance_->pp_instance(), force_async_);
+
+ pp::FileSystem file_system(instance_, PP_FILESYSTEMTYPE_LOCALTEMPORARY);
+ int32_t rv = file_system.Open(1024, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::Open force_async", rv);
+ if (rv == PP_OK_COMPLETIONPENDING)
+ rv = callback.WaitForResult();
+ if (rv != PP_OK)
+ return ReportError("FileSystem::Open", rv);
+
+ // Make a directory.
+ pp::FileRef dir_ref(file_system, "/test_dir_open_directory");
+ rv = dir_ref.MakeDirectory(callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileSystem::MakeDirectory force_async", rv);
+ if (rv == PP_OK_COMPLETIONPENDING)
+ rv = callback.WaitForResult();
+ if (rv != PP_OK)
+ return ReportError("FileSystem::MakeDirectory", rv);
+
+ // Open the directory. This is expected to fail since directories cannot be
+ // opened.
+ pp::FileIO file_io(instance_);
+ rv = file_io.Open(dir_ref, PP_FILEOPENFLAG_READ, callback);
+ if (force_async_ && rv != PP_OK_COMPLETIONPENDING)
+ return ReportError("FileIO::Open force_async", rv);
+ if (rv == PP_OK_COMPLETIONPENDING)
+ rv = callback.WaitForResult();
+ // Check for failing open operation for the directory.
+ if (rv != PP_ERROR_NOTAFILE)
+ return ReportError("FileIO::Open", rv);
+
+ PASS();
+}
+
std::string TestFileIO::TestReadWriteSetLength() {
TestCompletionCallback callback(instance_->pp_instance(), force_async_);
diff --git a/ppapi/tests/test_file_io.h b/ppapi/tests/test_file_io.h
index bf1c798..8db0ba1 100644
--- a/ppapi/tests/test_file_io.h
+++ b/ppapi/tests/test_file_io.h
@@ -38,6 +38,7 @@ class TestFileIO : public TestCase {
};
std::string TestOpen();
+ std::string TestOpenDirectory();
std::string TestReadWriteSetLength();
std::string TestReadToArrayWriteSetLength();
std::string TestTouchQuery();