diff --git a/indra/llappearance/llwearable.cpp b/indra/llappearance/llwearable.cpp
index 4bce3f99ed8fd4719c2becf083aa661b2bc8f9a4..41c06f4368336cfee6e8369e7e0b3bb2ebd517d6 100755
--- a/indra/llappearance/llwearable.cpp
+++ b/indra/llappearance/llwearable.cpp
@@ -86,10 +86,10 @@ LLAssetType::EType LLWearable::getAssetType() const
 	return LLWearableType::getAssetType(mType);
 }
 
-BOOL LLWearable::exportFile(LLFILE* fp) const
+BOOL LLWearable::exportFile(const std::string& filename) const
 {
-	llofstream ofs(fp);
-	return exportStream(ofs);
+	llofstream ofs(filename, std::ios_base::out | std::ios_base::trunc | std::ios_base::binary);
+	return ofs.is_open() && exportStream(ofs);
 }
 
 // virtual
@@ -201,10 +201,11 @@ void LLWearable::createLayers(S32 te, LLAvatarAppearance *avatarp)
 	}
 }
 
-LLWearable::EImportResult LLWearable::importFile(LLFILE* fp, LLAvatarAppearance* avatarp )
+LLWearable::EImportResult LLWearable::importFile(const std::string& filename,
+												 LLAvatarAppearance* avatarp )
 {
-	llifstream ifs(fp);
-	return importStream(ifs, avatarp);
+	llifstream ifs(filename, std::ios_base::in | std::ios_base::binary);
+	return (! ifs.is_open())? FAILURE : importStream(ifs, avatarp);
 }
 
 // virtual
diff --git a/indra/llappearance/llwearable.h b/indra/llappearance/llwearable.h
index 630eb1e3a5fe71fe802266c6fd8485e4961b8f7a..875c2932f15adf05c4f478cfd4874fcc64818f5d 100755
--- a/indra/llappearance/llwearable.h
+++ b/indra/llappearance/llwearable.h
@@ -81,8 +81,8 @@ class LLWearable
 		SUCCESS,
 		BAD_HEADER
 	};
-	BOOL				exportFile(LLFILE* file) const;
-	EImportResult		importFile(LLFILE* file, LLAvatarAppearance* avatarp );
+	BOOL				exportFile(const std::string& filename) const;
+	EImportResult		importFile(const std::string& filename, LLAvatarAppearance* avatarp );
 	virtual BOOL				exportStream( std::ostream& output_stream ) const;
 	virtual EImportResult		importStream( std::istream& input_stream, LLAvatarAppearance* avatarp );
 
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index aabc195ba8e5e6d461625b0a186477b02250c0f2..304d702979c9a8b7273df01db88cdfcebe64fad8 100755
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -919,6 +919,7 @@ llifstream::llifstream(const char* _Filename,
 #endif
 
 
+#if llstream_LLFILE
 // explicit
 llifstream::llifstream(_Filet *_File,
 		ios_base::openmode _Mode, size_t _Size) :
@@ -942,6 +943,7 @@ llifstream::llifstream(int __fd,
 	this->init(&_M_filebuf);
 }
 #endif
+#endif // llstream_LLFILE
 
 bool llifstream::is_open() const
 {	// test if C stream has been opened
@@ -1039,6 +1041,7 @@ llofstream::llofstream(const char* _Filename,
 }
 #endif
 
+#if llstream_LLFILE
 // explicit
 llofstream::llofstream(_Filet *_File,
 			ios_base::openmode _Mode, size_t _Size) :
@@ -1062,6 +1065,7 @@ llofstream::llofstream(int __fd,
 	this->init(&_M_filebuf);
 }
 #endif
+#endif // llstream_LLFILE
 
 bool llofstream::is_open() const
 {	// test if C stream has been opened
diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h
index 0612071d67408114ad397829df201219ac764cd0..44a1e42fa5ad2de97a09ddee7d6c3274520003bc 100755
--- a/indra/llcommon/llfile.h
+++ b/indra/llcommon/llfile.h
@@ -86,6 +86,12 @@ class LL_COMMON_API LLFile
 	static  const char * tmpdir();
 };
 
+// Remove ll[io]fstream support for [LL]FILE*, preparing to remove dependency
+// on GNU's standard library.
+#if ! defined(llstream_LLFILE)
+#define llstream_LLFILE 0
+#endif
+
 /**
  *  @brief Provides a layer of compatibility for C/POSIX.
  *
@@ -228,6 +234,7 @@ class LL_COMMON_API llifstream	:	public	std::istream
 	explicit llifstream(const char* _Filename,
 			ios_base::openmode _Mode = ios_base::in);
 
+#if llstream_LLFILE
 	/**
 	 *  @brief  Create a stream using an open c file stream.
 	 *  @param  File  An open @c FILE*.
@@ -253,6 +260,7 @@ class LL_COMMON_API llifstream	:	public	std::istream
 			//size_t _Size = static_cast<size_t>(BUFSIZ));
 			size_t _Size = static_cast<size_t>(1));
 #endif
+#endif // llstream_LLFILE
 
 	/**
 	 *  @brief  The destructor does nothing.
@@ -263,6 +271,7 @@ class LL_COMMON_API llifstream	:	public	std::istream
 	virtual ~llifstream() {}
 
 	// Members:
+#if llstream_LLFILE
 	/**
 	 *  @brief  Accessing the underlying buffer.
 	 *  @return  The current basic_filebuf buffer.
@@ -271,6 +280,7 @@ class LL_COMMON_API llifstream	:	public	std::istream
 	*/
 	llstdio_filebuf* rdbuf() const
 	{ return const_cast<llstdio_filebuf*>(&_M_filebuf); }
+#endif // llstream_LLFILE
 
 	/**
 	 *  @brief  Wrapper to test for an open file.
@@ -340,6 +350,7 @@ class LL_COMMON_API llofstream	:	public	std::ostream
 	explicit llofstream(const char* _Filename,
 			ios_base::openmode _Mode = ios_base::out|ios_base::trunc);
 
+#if llstream_LLFILE
 	/**
 	 *  @brief  Create a stream using an open c file stream.
 	 *  @param  File  An open @c FILE*.
@@ -365,6 +376,7 @@ class LL_COMMON_API llofstream	:	public	std::ostream
 			//size_t _Size = static_cast<size_t>(BUFSIZ));
 			size_t _Size = static_cast<size_t>(1));
 #endif
+#endif // llstream_LLFILE
 
 	/**
 	 *  @brief  The destructor does nothing.
@@ -375,6 +387,7 @@ class LL_COMMON_API llofstream	:	public	std::ostream
 	virtual ~llofstream() {}
 
 	// Members:
+#if llstream_LLFILE
 	/**
 	 *  @brief  Accessing the underlying buffer.
 	 *  @return  The current basic_filebuf buffer.
@@ -383,6 +396,7 @@ class LL_COMMON_API llofstream	:	public	std::ostream
 	*/
 	llstdio_filebuf* rdbuf() const
 	{ return const_cast<llstdio_filebuf*>(&_M_filebuf); }
+#endif // llstream_LLFILE
 
 	/**
 	 *  @brief  Wrapper to test for an open file.
diff --git a/indra/newview/llviewerwearable.cpp b/indra/newview/llviewerwearable.cpp
index 7de82a4710856ffa096304595d5e881054526130..0f73515b5d8331909708758fa9a2baa8b14425b0 100755
--- a/indra/newview/llviewerwearable.cpp
+++ b/indra/newview/llviewerwearable.cpp
@@ -509,18 +509,7 @@ void LLViewerWearable::saveNewAsset() const
 	//LL_INFOS() << *this << LL_ENDL;
 
 	const std::string filename = asset_id_to_filename(mAssetID);
-	LLFILE* fp = LLFile::fopen(filename, "wb");		/* Flawfinder: ignore */
-	BOOL successful_save = FALSE;
-	if(fp && exportFile(fp))
-	{
-		successful_save = TRUE;
-	}
-	if(fp)
-	{
-		fclose(fp);
-		fp = NULL;
-	}
-	if(!successful_save)
+	if(! exportFile(filename))
 	{
 		std::string buffer = llformat("Unable to save '%s' to wearable file.", mName.c_str());
 		LL_WARNS() << buffer << LL_ENDL;